Warning: Backup the file before playing with it!
What does this file do?
The HOSTS file found on Windows (and linux too) is like a local DNS (domain name server). When you type a url on the browsers address bar, the domain name is converted to the IP of the server by a DNS lookup by the browser. Now here is the catch ... Windows first looks at the HOSTS file before doing any DNS lookup. So we can block certain sites by editing the HOSTS file.
Where is it ? I dont see the HOSTS file
HOSTS file is found typically here ...
Windows XP : C:\WINDOWS\SYSTEM32\DRIVERS\ETC
Windows 2K : C:\WINNT\SYSTEM32\DRIVERS\ETC
Windows 98/ME : C:\WINDOWS
Linux : /etc/
What is in this FILE?
HOSTS file is just a plain text file. So you can use any text editing software like notepad to edit the contents of the file.
Typical content of a HOSTS file is shown below :
# Copyright (c) 1993-1999 Microsoft Corp.
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
# For example:
# 126.96.36.199 rhino.acme.com # source server
# 188.8.131.52 x.acme.com # x client host
The Lines followed by a # are comments and explains how to use the HOSTS file. 127.0.0.1 is the IP address that is used to loopback to your computer itself. So if you are running an apache or IIS server or anyother server software, you can access it by the url http://localhost or http://127.0.0.1
What now ?
Suppose you want to block some sites for example say you want to block "www.sicksite.com". All you have to do is add another line to the HOSTS file:
Now what happens is whenever you try to visit "www.sicksite.com" it goes to the site on your localhost. For common people those who dont run any server, localhost is nowhere!
Why would i want to block sites ?
There are many parasitic servers out there on the internet, that track your movements while browsing. So if you want to protect yourself, include those sites on the HOSTS file.
A list of sites that is parasitic or is an ad serving site is given in
It is not recommended to copy the entire list to your local HOSTS file as it slows down the system. So choose ones that you think needs to be blocked.
What is this pop up about?
When you are saving the HOSTS file, a pop up may appear that asks you to confirm the changes to the HOSTS file. This pop up may or may not appear based on the OS, and other Anti-Virus Softwares you are running.
What else can I do with "HOSTS" file?
You can also make a site point to another site. By making an entry as follows :
184.108.40.206 www.mysearchengine.com #220.127.116.11 google server ip
Now visiting "www.mysearchengine.com" takes you yo "www.google.com".
To find out IP address of sites visit:
If your are a webmaster, HOSTS file allows you to make subdomains within localhost (depends on server software and after configurations in it).
Oops I screwed up ...
Restore the backup file if u have already done so
Copy the sample HOSTS given above and save it.
Still confused? Have more queries?
If you are having more doubts, please feel free to leave a comment ....