Editing the HOSTS file on Windows, Mac and Linux

The HOSTS file takes the structure of the IP address you wish to point to followed by the hostname you are mapping to it. E.g. nethosted.co.uk www.nethosted.co.uk

This format remains the same across operating systems, however the location of the hosts file does vary. Here is where you can find it on different operating systems:

  • Windows 95/98/Me: C:\windows\hosts
  • Windows NT/2000/XP Pro: C:\winnt\system32\drivers\etc\hosts
  • Windows XP Home: C:\windows\system32\drivers\etc\hosts
  • Windows Vista/7/8/8.1/10: C:\windows\system32\drivers\etc\hosts
  • Mac OS X: /private/etc/hosts
  • Linux: /etc/hosts

On Windows Vista and above (7/8/8.1/10) they have unfortunately decided to make things more complicated and less accessible, but it’s still possible to make changes to this. You need to edit the file with administrator rights:

  1. Start Menu -> All Programs -> Accessories
  2. Right click “Notepad” and choose “Run as administrator”
  3. Click “Continue” on the security prompt
  4. Select File -> Open
  5. Browse to “C:\Windows\System32\Drivers\etc”
  6. Change the file filter selection from “Text Documents (*.txt)” to “All Files (*.*)”
  7. Select the “hosts” file and “Open”
  8. Make the changes that you require and save the file.

For Mac OS X

  1. Start typing Terminal in the Spotlight search(cmd+space), or from Applications > Utilities > Terminal.
  2. Open the hosts file by running this command in Terminal, typing your OSX user password when prompted:  sudo nano /private/etc/hosts
  3. Add the new hosts entry underneath the existing ones at the bottom of the file.
  4. Press CONTROL+O to save and press ENTER when prompted.
  5. CONTROL-X to exit nano.
  6. Running the following in the Terminal window will flush the DNS cache so this takes effect immediately: dscacheutil -flushcache

For Linux you should edit /etc/hosts with your favourite text editor from the root account or using sudo.


After you have set this you can just visit the website in your browser (it may need to be restarted first) and the site will then load from our servers. Using the browsers built in private browsing mode can also help to avoid caching here.

Using this method can save you a lot of headaches in the site development process, and offers you the flexibility to develop your site from anywhere without having to change the DNS servers on your web hosting. It also removes the need to consider DNS caching and propagation.


Was this answer helpful?

Also Read

How do I use an external mailserver with my hosting

If you are using an external DNS provider then the correct way to set up an external mailserver...

Taking a Traceroute (tracert) in Windows

To take a traceroute (in windows this is done by the application called tracert) you need to open...

How to install a WordPress blog in 1 minute on NetHosted

We’ve produced a quick video guide on how to get started with WordPress on NetHosted. By...

What nameservers should I use

The nameservers you use vary depending on which server you are hosted on as follows:...

Enabling HTTPS/SSL on a WordPress Website

Once you have purchased an SSL Certificate and dedicated IP and this has been installed by us you...