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.’
Your computer will now search for savvii.nl and www.savvii.nl 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.
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 savvii.nl. It will also say whether the contact was made succesfully. Your computer receives responses from the IP address, which means the connection is good.