The Hosts file contains the mappings of IP addresses to host names. This file is loaded into memory (cache) at startup, then Windows checks the Hosts file before it queries any DNS servers, which enables it to override addresses in the DNS. This prevents access to the listed sites by redirecting any connection attempts back to the local machine. Another feature of the HOSTS file is its ability to block other applications from connecting to the Internet, providing the entry exists. It’s a general practice of web developers to test any site locally by emulating the original web address pointing to a local or development server by modifying the hosts file. Here is a brief explanation on how to set it up properly.
The host file is located in different locations in different operating systems and even in different Windows versions:
- Windows NT/2000/XP/Vista:
%SystemRoot%system32driversetcis the default location, which may be changed. The actual directory is determined by the Registry key
- Windows 95/98/Me:
- Linux and other Unix-like operating systems:
- Mac OS 9 and earlier: System Folder: Preferences or System folder (format of the file may vary from Windows and Linux counterparts)
- Mac OS X:
/private/etc(uses BSD-style Hosts file)
- OS/2 and eComStation:
Setting it up:
- Locate the file "Hosts" on your computer:
Windows 95/98/Me c:windowshosts
Windows NT/2000/XP Pro c:winntsystem32driversetchosts
Windows XP Home c:windowssystem32driversetchosts
(you may need administrator access for Windows NT/2000/XP)
NOTE: Hosts is the name of the hosts file and not another directory name. It does not have an extension (extensions are the .exe, .txt, .doc, etc. endings to filenames) and so appears to be another directory in the example above.
You may have a file called "Hosts.sam". This file is a sample Hosts file (the .sam stands for sample) and can be used by removing the .sam extension so the name is just "Hosts". This file should be edited with a text editor, such as Notepad, and not a word processor, such as Microsoft Word. Use whatever you normally use to edit your text and source code files.
( you can run this too:
notepad.exe C:WindowsSystem32driversetchosts )
- Add this line to the Hosts file:
- Save your changes.
- Reboot your computer.
Your server should now "register" with the Live Directory at dev.integricity.com.
- If your Hosts file already contains an entry for dev.integricity.com, then remove that entry. The above entry would be used in place of, and not in addition to any other dev.integricity.com entry.
NOTE: Windows users should verify that they are showing extensions for all file types. This will help verify that the Hosts file is named correctly. To reset Windows to show all file extensions, double click on My Computer. Go to View Menu (Win95/98/ME) or Tools Menu (Win2000/XP), and select Folder Options. Click the View tab. In the Files and Folders section, DESELECT (uncheck) the item named "Hide file extensions for known file types". Click Apply, and then click OK.
Additional for Windows: Open Command prompt and type ipoconfig /flushdns then ipconfig /renew
Make sure you are not using any proxy server, check Internet options.
Tools to make your life easier (1)
HostsMan is a freeware application that lets you manage your Hosts file.
Includes an option to easily turn off the unneeded DNS Client Service.
This also has an option to update the existing HOSTS file when needed.
Important! – make sure you select: Default action – Overwrite
Use the Server option to replace the Action Cancelled message.
HostsXpert is a terrific multi-function Hosts File Manager
Note: no install required, it runs from anywhere … when updating the HOSTS file make sure to use the Replace option, rather than Merge.
Windows Vista: You can use HostsXpert to update the HOSTS file, however you’ll need to right-click on "HostsXpert.exe"
Next select: Properties and click Unblock, then click Apply, next click the Compatibility tab
Place a check in "Run as administrator", click Apply/Ok … it a little quirky but it works …
- Edit the hosts file on your system. The hosts file is usually found in
- Add this entry to the Hosts file:
- Now make sure this file is used for host name lookups. This is done in two files. First is:
This file should have at least the line shown below:
That has host lookups use the hosts file before doing a DNS query with bind.
- The next file is:
Recent tests indicate that this file is required in order for the pserver to use the entry in /etc/hosts. The nsswitch.conf file should have this line for the hosts configuration:
hosts: files nisplus nis dns
There will probably already be a similar line in your version of this file. Just make sure "files" comes before whatever other methods are listed.
It should now "register" with the Live Directory at dev.integricity.com.
NOTE: The above configuration instructions were tested with a linux 4.5.1 Palace server, and should also work with the linux 4.4.1 server. The 4.3.2 linux server did not respond to the above configuration when tested. Older versions were not tested.
- With Macintosh OS X, the procedure is similar to Linux above. The hosts file can be found in
- Look in System Folder:Preferences, and in the System Folder itself, and see if you have a file named "Hosts". If not, create one in a text editor.
- Add these entries to the Hosts file:
test.integricity.com A 127.0.0.1 dev.integricity.com A 220.127.116.11
- Spaces should work, but it is recommended that you separate the three entries on each line by tabs. The first line is the one that makes sure your downloads work, and the second line is the one that redirects your server’s reporting information. Place the Hosts file in System Folder:Preferences and reboot your Mac. It should now "register" with the Live Directory at dev.integricity.com.
If you have an older Mac that is using MacTCP instead of Open Transport, try putting the Hosts file in the System Folder.
Note from the Apple Tech Info Library:
Open Transport TCP/IP automatically uses a Hosts file stored the Preferences folder of the active System Folder. If no Hosts file is found in the Preferences folder, Open Transport TCP/IP searches the active System Folder for a Hosts file.
This means that if you don’t already have a Hosts file, and you just drop it in your System Folder and reboot, it will work. However, System Folder:Preferences is the default and recommended location for all systems using Open Transport.
- Additional Configuration Options
You can configure TCP/IP to use the contents of this new Hosts file, which will activate the Hosts file without having to reboot.
To do this:
- Open the TCP/IP control panel.
- Get into Advanced user mode by:
- selecting the User Mode command under the Edit menu.
- In the User Mode dialog select Advanced then click OK.
- Click on the Select Hosts File button.
- In the File Open file dialog that comes up, naviagate to and select the Hosts file you created.
- Click on OK if it asks you if you are sure you want to replace the Hosts File with the contents of the selected file.
- Close TCP/IP control panel and click OK to save the configuration.
The above procedure will copy the contents of the file selected into the Hosts file in the Preferences folder, or create one there if none exists.