Modifying your hosts file will allow you to access a website on an IP address that is not publicly available in DNS. An example of this is when you are migrating a website from one host to another and want to access the site on the new host’s IP address to verify everything looks proper before you update your DNS and make it live.
You must have administrator privileges to modify your hosts file. Don’t forget to remove the entry when you are done reviewing your website. Entries left on your hosts file will override DNS settings from the computer.
Your hosts file will need one or two entries that contain the IP address that you want the website to resolve to (93.184.216.119 used for example purposes) and the website address (example.com used for example purposes). You may also need to refresh your browser or completely close and reopen your browser for the new entries to take effect. The entries should look something like what is displayed below at the very bottom of the hosts file.
93.184.216.119 example.com
93.184.216.119 www.example.com
Below are instructions for how to find your hosts file on your computer.
On a Windows Operating System
- Find “notepad” in your Programs > Accessories
- Right click on “notepad” and say “Run as Administrator”
- Click “open” in notepad and go to the file located at: c:/windows/system32/drivers/etc
- No files will appear since they are hidden so type “hosts” in the “file name” field
On an Mac Operating System
- Open the Terminal Application (Applications > Tools > Terminal)
- Type “sudo nano /etc/hosts” and click “Return”
- Enter your password
- This will open the hosts file. From here, you can scroll to the bottom of the file and enter the IP address and website you want to resolve to that IP address.
- Exit and Save, press “control” and “x” then you will be prompted to save and click “Y” to save.