Howto Set a Static Host Entry
Introduction
When looking to move your website to a new server you may first want to check that it loads correctly and as expected before making DNS changes which will push visitors to the new website. This can be achieved by tricking your computer or device into forcefully loading a website from a specific IP address. Below you’ll find instructions on how to modify your host files for both Windows and OS X.
It is important to note that when you carry this out your PC will not be able to see the live server of your domain. As a result you may not be able to successfully send emails or receive emails from that domain until the line is removed from your hosts file after checking the website.
Windows
1) You’ll need to open Notepad as Administrator, this can be done by typing Notepad into Start Menu, right-clicking and then selecting Run as Administrator.
2) Next open the hosts file on your PC by going to File -> Open -> C:\Windows\System32\drivers\etc
Select “All Files” on the bottom right to reveal files that are not in .txt format.
Open the “hosts” file and you’ll see a file that looks very similar to the below.
3) At the bottom of the file you want to add a line containing the IP address of your new server and the domain name you want to visit. In this example, we have added:
10.10.99.99 fractionservers.com
4) Close and save the file.
Mac OS X
1) Open Terminal by going to Applications -> Utilities -> Terminal
2) Copy and paste in the following line into the terminal window to open the hosts file.
sudo nano /private/etc/hosts
Enter your password when prompted
3) At the bottom of the file you want to add a line containing the IP address of your new server and the domain name you want to visit. In this example, we have added:
10.10.99.99 fractionservers.com
4) Close and save the file by pressing CTRL + X and then Y when prompted to save changes.
5) Flush the cache to update the cache to see the newly added changes with the following command.
dscacheutil -flushcache
Testing the changes have worked
You can now test the website in the browser and should see the website on the server with the new IP address. You can verify this has worked by pinging the domain name in cmd or terminal where you should now see the new IP address that you have just entered into your host file:
C:\Users\FractionServers>ping fractionservers.com Pinging fractionservers.com [10.10.99.99] with 32 bytes of data: Reply from 10.10.99.99: bytes=32 time=1ms TTL=61
Note that some browsers cache the DNS lookups too until it is fully closed so it is best to visit the site in a new Incognito window.