Modifying the Windows Hosts File

Windows contains a file named hosts that allows you to override where your browser looks for a website. This is useful when you need to test a website on a new server before pointing the domain to that new location to make it live.


Opening Notepad

The first step you take depends on the version of Windows that you are using.

Windows XP
Nothing special is needed in XP, simply open up Notepad from your Start Menu.

Windows Vista and 7
Find Notepad in the Start Menu and right click it, this will present you with a set of options from which you need to select the one that says Run as Administrator. Once you have clicked this Notepad should launch.

Windows Vista and 7 Notepad

Windows 8 and 8.1
Bring up the Metro (Start Menu) interface and find Notepad (you can type to search). Then right click the Notepad icon and select Run as Administrator from the bottom of the screen. Notepad will now start.

Windows 8 Notepad

Editing Hosts

Now you need to open the hosts file inside Notepad to make the required changes. This file is typically located here in…

C:\Windows\System32\drivers\etc\hosts

Normally, if you have not edited this file before, you will see a couple of existing entries that refer to localhost. This is normal and these should be left alone.

To preview your website, you need to enter the IP address of your new server followed by a space and then the address of the website, like so:

123.123.123.123 example.org 
123.123.123.123 www.example.org

Replacing 123.123.123.123 with the real IP address of your new server and example.org with your domain name. Any additional domains you wish to use should be added individually on new lines at the bottom of this file.


Finished

Save the file when you have finished making your changes and reload your web browser. You should now be able to preview your website from the location you have specified.


Was this article helpful?

Related guides