World Wide Mart Inc
Please Login or Register

Knowledgebase

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:

127.0.0.1       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:

67.225.137.27       worldwidemart.com www.worldwidemart.com

As you can see, this will redirect both worldwidemart.com and www.worldwidemart.com to the IP address of 67.225.137.27.  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.

Windows

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

%SystemRoot%\system32\drivers\etc\
(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

OR

  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

MacOS

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

/private/etc/hosts

You will need administrative privileges to edit this file.

Linux

On Linux, you can find the hosts file here:

/etc/hosts

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.



Was this answer helpful?

Add to Favourites Add to Favourites

Print this Article Print this Article

Also Read
Webalizer (Views: 1296)
Analog (Views: 1344)
Bandwidth (Views: 1322)
Awstats (Views: 1582)
Error Log (Views: 1289)

Powered by WHMCompleteSolution

Language:

Quick Navigation

Live Help

Live Help

Client Login

Email

Password

Remember Me

Search



Follow Us on Twitter