Editing your hosts file

A hosts file allows your computer to override the DNS records.

Sorry, what?

The Domain Name System (DNS) is a database that records information, such as the IP address, about domain names like https://webworks.london. While webworks.london is the name of our website, it isn’t its address. In order for your web browser to find our website, it needs to know where to look. DNS allows your browser to check our domain name against an IP address so that it knows how to find our site.

Ok, so what?

Sometimes, you’ll want to override the global DNS records so that a particular domain returns an address different to the DNS listing. Often, we develop new websites using the same domain name as your old site, but the new site is actually located on our secure development host. In order for your browser to reach the new site, you need to tell your hosts file where to look, instead of automatically following the address from DNS.

The process is slightly different depending on whether you’re using a Mac or a PC. If you’re using something else, drop us a line and we’ll talk you through it.

Opening your hosts file on a PC

  • Click Windows key and R at the same time
  • Enter “notepad”  and right click the Notepad desktop app icon
  • Select “Run as Administrator”
  • In Notepad, open “c:windowssystem32driversetchosts”

Opening your hosts file on a Mac

  • Go to Utilities and open Terminal
  • In the terminal, type: sudo nano /etc/hosts
  • Enter your password (note that you won’t be able to see the password you’re typing so do it carefully) and press Return

Editing your hosts file

You should now have your hosts file open. Each line of the hosts file identifies an IP address followed by the domain name to associate with the address. We will have sent the details to paste into this file by email.

  • Paste or type the IP address and domain name into the bottom of your hosts file.

For example, we may have asked you to paste the following:

123.12.456.78 www.yoursite.com

123.12.456.78 yoursite.com

These entries tell your PC that when your browser requests the site www.yoursite.com, it should look for it at the IP address 123.12.456.78.

  • Next, you’ll need to save the file in order to implement the change. To do this, press Ctrl+S (if you’re using a PC) or Command+X followed by ‘y’ and Return (if you’re using a Mac).

When you need to look at your old site again or when your new site has launched, you’ll need to amend your hosts file so that the DNS sends you to the correct address.

If you want to do this temporarily, you should follow the same process above, and place a hash ‘#’ at the front of the line containing the record.

For example, the line:

123.12.456.78 www.yoursite.com

will send your browser to 123.12.456.78 when you navigate www.to yoursite.com, but:

#123.12.456.78 www.yoursite.com

does nothing. Remember to save the file to implement the change.

To remove the record permanently, follow the process above and remove the line completely before saving.

Having difficulties?

Feel free to drop us a line if you’re having trouble.

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply