The HOSTS file on your Windows PC or MAC is used by the operating system as a place to lookup hostnames for IP addresses before checking DNS. Let's explain:
When you need to go to www.somedomain.com, your computer needs to actually "resolve" that name to an IP address... i.e., what is the IP address of the server that is hosting www.somedomain.com. To resolve that IP address, your system will FIRST look in your HOSTS file, which is simply a text file with a list of hostnames mapped to IP addresses. Typically, it's empty, as it's just there for specific purposes. When www.somedomain.com isn't found there, then your computer will check with your ISP's DNS servers (ISP = Internet Service Provider).
As you can see, because your computer checks in this order, hosts file first, then DNS servers, if you put an entry in your hosts file, you can effectively override what is in DNS. A neat trick that's helpful sometimes in troubleshooting, or publishing a site with FrontPage before DNS is actually pointing to the right IP address.
To edit your HOSTS file on a Mac, please refer to this article: http://knowledge.3essentials.com/web-hosting/article/1313/How-To-Edit-HOSTS-file-on-Mac-OS-X.html
To edit your hosts file on Windows, follow these steps:
- Open Windows Explorer on your system
- Navigate to c:\windows\system32\drivers\etc
- Find the file named "hosts" (it has no file extension), and double click it.
- Windows will ask you if you want to open it and what to open it with, choose to open it with Notepad (notepad.exe).
- Once the file is open, you can add the necessary lines. If our support team is asking you to modify your hosts file, they will provide you the exact line to enter. The line will be in the format of:
- 220.127.116.11 somedomain.com
- 18.104.22.168 somedomain.com ftp.somedomain.com www.somedomain.com
- where "22.214.171.124" equals the ip address you need to point to and "somedomain.com" is the hostname you need to map/resolve the IP to.
- Important notes when editing a hosts file:
- NOTE for Windows Vista and Windows 7 users: By default, if you try to modify your host file in Vista, it will not let you save it. It tells you that you don't have permission. To successfully modify the hosts file, run notepad.exe as an administrator and open the file.
- Browse to Start -> All Programs -> Accessories
- Right click "Notepad" and select "Run as administrator"
- Click "Continue" on the UAC prompt
- Click File -> Open
- Browse to "C:\Windows\System32\Drivers\etc"
- Change the file filter drop down box from "Text Documents (*.txt)" to "All Files (*.*)"
- Select "hosts" and click "Open"
- Make the needed changes and close Notepad. Save when prompted.
- NOTE for MAC users:
- The following may or may not work on all versions of the MAC OS... if it does not, please consult your MAC OS documentation for how to edit the HOSTS file.
- Open Finder.
- In the Go menu, select "Go to Folder"
- Type /etc for the folder name.
- In the list of files that appears, you should find hosts. Make a backup copy of the hosts file first. Then, double it to open it in a text editor (the hosts file, not your backup copy) .
- add the hosts file entry provided by the support team as a new line to the file and save it.