The hosts file decides which IP address your computer uses to search for a site. This is very useful when you, for example, want to test your site on a new server. By adding a line in the hosts file you can make your computer search this new server, while other visitors see the live site. Using this, you can simulate a DNS (Domain Name System) transfer. After editing your hostfile, if you use your browser to visit your domain or one of the other domains in your hosts file to our server, your browser will use our server to get to the domain’s content. Your browser will show the live domain, while you are in fact browsing on our new server. In this short tutorial we will show you how to edit the hosts file on a Windows computer. If you are using a Mac computer, you can read how to edit your hosts file here.


- Go to ‘C:\Windows\System32\drivers\etc’ and open the ‘hosts’ file with notepad as administrator.



By opening as administrator you are making sure you can save the file after you are finished editing it. As you can see, the file itself provides an explanation on what it is used for.


- Add a line containing: the new IP address of the site + the name of the site with and without ‘www.’

- Save the file.


Your computer will now search for and on the newly added IP address. The live site will still be accessible to other visitors. If you want the site on the newly added IP address to go live, you will have to edit the DNS.


Test hosts file changes

You can use the ping command to check if the hosts file change succeeded. You can enter this command in the command prompt (cmd). When you use the ping command the computer tries to connect to the site, and then the prompt shows you which IP address was used to do so.


- Type ‘cmd’ in the Windows search bar (accessed by clicking the ‘Start’ button) and open the program.

- Enter the command ‘ping’ + the domain name.


- Press enter to execute the command.


You will now see which IP address the computer uses to access data when searching for It will also say whether the contact was made succesfully. Your computer receives responses from the IP address, which means the connection is good.


Restoring the hosts file

If you want to see the live site again, you have to remove the added line from the file, or add a hash symbol (#) in front of the line. When you use the hash symbol, your computer will read the line as a comment/notification, which means it does not change the configuration of your computer.