Wednesday, May 16, 2007

Get To Know Your Hosts File

What is the Hosts File
It is a plain text file located within your system directory. It has no file extension.

  1. Windows 2000 - c:\winnt\system32\drivers\etc\hosts
  2. Windows XP, 2003 - c:\windows\system32\drivers\etc\hosts
  3. You'll find equivalent files in other OS's (e.g. Unix)
What Does it Do?
Your Hosts file overrides DNS, forcing HTTP requests to route the way you specify.

Why is it Useful?
There are all kinds of uses for Hosts, depending on your problem at hand. Here are some examples:

  1. You set up numerous IIS sites (e.g. in a development environment (server OS), and want to test them via a browswer.
  2. You are developing a single site with multiple behaviors based on domain name (e.g. has a blue background; has a red background). You want to be able to test these behaviors.
  3. Your are troubleshooting your company's load-balanced server farm. Customers are complaining about a site/application, but you are having difficulty recreating. If the problem is isolated to a specific server, you can force http requests to each server in the farm, provided you have the list of IP addresses.
  4. You want to block various ad/banner nuisances.
Brief Example
You are developing a fictional site to IIS, running Windows XP. Call this site
  1. Open c:\windows\system32\drivers\etc\hosts in a text editor
  2. Add the following line:
  4. Save the file.
  5. Close any open internet browsers.
  6. Open a browser and go to

The request will open the home page of your default web site. If you've never used Hosts, give it a shot!


Anonymous said...

Thanks for posting such good information. Way to go buddy.

Anonymous said...


price per head said...

Great site!!! this information really helped me

pay per head said...

This is very great thing you have shared with us. Now I found enough resources by your tips about this issue, Thank you.

May said...

I think every person ought to read it.