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.
10.20.30.40 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:
- Start Menu -> All Programs -> Accessories
- Right click “Notepad” and choose “Run as administrator”
- Click “Continue” on the security prompt
- Select File -> Open
- Browse to “C:\Windows\System32\Drivers\etc”
- Change the file filter selection from “Text Documents (*.txt)” to “All Files (*.*)”
- Select the “hosts” file and “Open”
- Make the changes that you require and save the file.
For Mac OS X
- Start typing
Terminalin the Spotlight search(cmd+space), or from Applications > Utilities > Terminal.
- Open the hosts file by running this command in Terminal, typing your OSX user password when prompted: sudo nano /private/etc/hosts
- Add the new hosts entry underneath the existing ones at the bottom of the file.
- Press CONTROL+O to save and press ENTER when prompted.
- CONTROL-X to exit nano.
- 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?
Yes all of our servers come with Apache’s mod_rewrite module. You can use it via the .htaccess...
The formmail script that we recommend is Tectite PHP Formmail which is a very comprehensive,...
We’ve produced a quick video guide on how to get started with Drupal on NetHosted. By following...
There may be some circumstances where you wish to flush the DNS cache, when you move your account...
We’ve produced a quick video guide on how to get started with WordPress on NetHosted. By...