Editing the HOSTS file on Windows, Mac and Linux Print

  • 5

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

You can find your domain IP address listed in your welcome email and in your cPanel account, all domains on a cPanel account have the same IP address.

This format remains the same across operating systems.


On Windows 10 you need to edit the file with administrator rights:

  1. Start Menu -> Search for Notepad
  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.


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/10: C:\windows\system32\drivers\etc\hosts
Mac OS X: /private/etc/hosts
Linux: /etc/hosts


Was this answer helpful?

« Back