DNS Hosts File

One of the most powerful tools available to somebody working on their site during a migration is their computer’s ‘hosts’ file.  This file is especially useful when migrating a site between two servers, or any other time when DNS might not be working properly.

Lets start with an example of the the information that would be found in a typical hosts file:       localhost

That is all you will generally see in a clean hosts file.  Its layout is tab or space delimited.  The first field in the line is the IP address that you would like the site to resolve to, and any additional fields after that should be domain names.  For example, if I wanted to reroute worldwidemart.com to some other location I might put a line in my hosts file that looks something like this:       worldwidemart.com www.worldwidemart.com

As you can see, this will redirect both worldwidemart.com and www.worldwidemart.com to the IP address of  When moving a site to a new server, you can use this file to test out your sites to ensure that they work after the move, while still leaving your original site online. Simply point the desired IP address at the domain name in question and you computer will connect to the new IP whenever you type in the domain name.

This file is located in a few different places depending on your operating system.  The file name is ‘hosts’ no matter what operating system you have.


On Windows XP/2003/Vista/7 this file is located in:

(Typically C:\Windows\System32\drivers\etc)

With Vista/Windows 7 you will need to edit this file with administrative privileges.  You can do this by following one of these two sets of instructions:

  1. Click on the Windows logo.
  2. Search for ‘notepad’
  3. Right click on the notepad launcher and select ‘Run As Administrator’
  4. Click File, then Open
  5. Browse to the folder mentioned above and select the hosts file


  1. Click on the Windows logo.
  2. Click on Search.
  3. Search for the word “hosts” (Please be advised this search can take several minutes to complete)
  4. Double click on the hosts file and choose notepad as the program to open the file once prompted


On Mac OS X, your hosts file is located here:


You will need administrative privileges to edit this file.


On Linux, you can find the hosts file here:


Depending on the distribution you may need administrative privileges to edit this file.

Please remember to revert the hosts file to its original state after the migration is complete.

  • 76 Users Found This Useful
Was this answer helpful?

Related Articles


The Analog reporting tool presents a comprehensive coverage of web server statistics available...


The Awstats reporting tool combines a comprehensive coverage of web server statistics available...


The Webalizer tool creates a graphical summary display of usage of your site. This is useful to...


The Bandwidth tool generates an overall summary of the amount of bandwidth that your site is...

Error Log

The error log contains all HTTP errors that occur when visitors attempt to view your site, such...