Skip to content

It’s come up several times in the last few weeks that I’ve needed to test a web site that was using host headers (in one form or another) but the DNS entries didn’t point to the server yet.  So I’ve had to walk some folks through the process of setting up their computer test the server.

Host headers are used by many ISPs to allow your web site and hundreds of other web sites to share one IP address.  When your web browser issues a request for a web site it goes to a specific IP address and opens a socket.  It then sends a request for the page it wants and includes the host name of the server it’s trying to reach — rather than the IP address.  Web servers can use this information to direct your request to the right web site.  The problem comes in when you want to test a site before the DNS is setup to reach it.

The magic of working around the problem lies in the %WINDIR%\System32\drivers\wayetc\hosts file.  This file is checked before DNS and is a great way to temporarily override the resolution of a name to any ip address you want.

The file has an example in the ever useful localhost entry.  You can copy this format to add in the ip address and then host name of the server you want to reach that is doing host header direction to sites.  Once the entry is made and the file is saved the changes are immediate.  You can test this at the command line by issuing a ping command and seeing that the IP address for the server is the IP address you entered into the file.

No comment yet, add your voice below!


Add a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Share this: