Using Windows Hosts file to prepare for website launch

Published on
8,677 Points
Last Modified:
As a web developer you often don't have access to internal DNS servers to test websites that you are working on.
As an alternative we can use the Windows Host File.  This allows me to use internet Explorer to view the actual URL without making it live on the internet.
This allows me to test and configure the site using the correct base URL as it awaits domain propagation.

To make the required changes to your hosts file the following steps should be completed:

Step 1 - On a Windows machine click the Start button and in the Accessories folder find Notepad – but don’t left click it open, instead right click for a menu that includes the option to “Run as administrator” – select this and Notepad will open.
The reason we do this is that on windows Vista and Windows 7 computers the host file cannot be edited using regular permissions so Run As Administrator is required.

Step 2 - Use the File menu in Notepad to select Open… then browse to %systemroot%\System32\drivers\etc – you will probably see a blank folder and this is because by default Notepad is set to look for files of type .txt – so using the drop down there select All Files (*.*) which will reveal the files without extensions, you should now see a file called “hosts” – open this file

At the bottom of the file insert your hosts directive which has the format of IP-address space domain-name, for example: domain.com

(do *not* use www. in your domain name!) once you have inserted this line click Save and close Notepad.

Now when you enter this domain name, without the www. part, in any of your browsers it will direct your request to the IP address you specified. To view the actual website the domain is pointing to before you switch it to the new server just use the www. in front of the domain e.g. www.domain.com – this will bypass your hosts directive.
Ask questions about what you read
If you have a question about something within an article, you can receive help directly from the article author. Experts Exchange article authors are available to answer questions and further the discussion.
Get 7 days free