Changing the Hosts file on a Mac or PC

Just as much for my own reference as for anything else, if you want to preview a website on a development server before changing DNS settings or nameservers, here’s how.

On a PC

Open the following file using Notepad:

Underneath all the entries (anything prefixed by a # is commented out), enter the following (replace the number with the IP address of your development server):


Save and close the hosts file. Restart your browser and you should see the development website under the correct domain name.

On Windows 7, you need to run Notepad as an administrator to be able to save the file.

On a Mac

Open Terminal. Type in:

sudo -s

Then type your password when prompted. The type:

$sudo nano /private/etc/hosts

This will open the hosts file – it looks much the same as the PC version. Change it in the same way as above. Control-O will save it.