/ Hosting

Hosting website on a local machine

When you are beginning your web development journey, especially the backend, one of the coolest things you could do is serve a website to the internet from your local machine. Though it is recommended not to do this for your production environment for the obvious reasons stated towards the end of this post, this is a great way to learn how the DNS works.


Just one

  • You will need your wifi router login username and password( which you might not know or your ISP won't give you! )

So let's get started!

Step 1 - Find your public IP address

This is pretty straight forward. Just google 'what is my ip' or go to this website whatismyip.

Step 2 - Get a domain name

For the purpose of this tutorial, we'll get a new one for free at Dot TK. Head over there and follow these steps

  • Settings > Register a New Domain
  • Search for an available domain, pick whatever you get and checkout
    Let's say we got testdomainname.gq

Step 3 - Point your domain name's DNS to your public IP

Use the Freenom DNS service and change the A record to point to your public IP that you found in step 1.

Step 4 - Setup a local web server

You could start your own server on a particular port on your machine.
But another cool thing you could do is, start a file directory based web server with a single command in python. Python comes pre-installed in mac and ubuntu, I'm not sure about windows.

  • Check if you have python installed by issuing this command python --version
  • Post python installation, run python -m SimpleHTTPServer 8080 in any directory.
    This should now start a web server that could be accessed in your web browser at http://localhost:8080. This server starts serving the files in the directory where the python command was run.

Step 5 - Port forward to your web server in the router

This is the final step and requires your router login credentials. Most of the steps that you will follow next are router specific and hence you might have to search for them extensively on the internet.

  1. Login to your router, the login page will be mostly available at or
  2. Assign yourself a static IP. So that even if you disconnect and connect to your wifi, the router gives you the same local IP. ex -
  3. Find the 'port-forwarding' settings for your router and port-forward your port 80 to the static IP with the port that you started your local web server on. ex -

Congratulations on finishing the tutorial.

It might take around 24 hours to update the DNS across the internet after which your new directory based web site will be available at testdomainname.gq or whatever domain name you chose.

But wait! things are not over yet. You must know why everybody in the world is not doing this.

Cons of hosting your website locally

  • Your website could be hacked, bots keep pinging for vulnerabilities
  • Personal computers are not designed for this kind of load nor are efficient for this. Think why would a web server need a display monitor?
  • You will have to keep your computer switched on all the time, your electricity bill would increase
  • You need 24x7 internet connectivity for your computer
  • Your IP address might change and then suddenly traffic from your domain might not reach your server
  • ISPs might ban you
Umang Ganvir

Umang Ganvir

Techie. Javascript Evangelist. Passionate Learner. Talks about Motivation and Value Creation.

Read More