Skip to content

HOSTS file


The HOSTS file is used to translate a host name to an IP (Internet Protocol) address without querying the DNS (Domain Name System) server.

For example, suppose you would like to search the web using Google. You start your browser and enter the '' host name. Communication on the Internet is based on IP addresses rather than host names, so behind the scenes the operating system checks if the HOSTS file has a mapping for to an IP address. If there's no mapping in the HOSTS file the operating system queries the DNS server that returns - which is Google's IP address - and then the browser requests Google's search page.

The remainder of the document provides more detailed information about the HOSTS file, such as how to edit it manually, how to use it for blocking content, known problems and work-arounds, etc.

HOSTS file example

The following is an example of a HOSTS file that redirects to, which is Yahoo's IP address. It also redirects to, which is Google's IP address. The line starting with # is a comment that will be ignored.

# An example HOSTS file.

Blocking unwanted content

The HOSTS file is often used to block potentially unwanted content, such as advertisements, cookies, hijackers, spyware, adware, pornography, etc.

If you know the host name of the machine that serves the unwanted content, you can redirect it to, which is the local IP address of your machine. For example, assume you have redirected the ad server to Every time your browser tries to load an image or a flash animation from the ad server, it will be redirected to your machine instead. As a result, the browser will not be able to show any content from this ad server.

Notification of blocked content

Unfortunately, there's no user-friendly notification when the HOSTS file blocks a site. In fact, Internet Explorer users will only get a general 'The page cannot be displayed' message, assuming you are not running a local web server. The same message appears when a web site is unavailable for other reasons that HOSTS file blocking.
If an image is blocked, you'll see a box with a red cross. Icon showed by Internet Explorer when an image is blocked by the HOSTS file The same box will also appear if the image is unavailable for reasons other than HOSTS file blocking.

Editing the HOSTS file

The HOSTS file is named 'hosts' and editable with any text editor, such as Notepad or Wordpad. Before editing, backup the current HOSTS file. The exact location of the file is determined by the 'HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\Tcpip\Parameters\DataBasePath' registry key. The file generally appears at:

Problems and workarounds

HOSTS file and machines using a proxy

Sometimes machines use a HTTP (Hyper Text Transfer Protocol) proxy to handle the task of downloading and caching web content. The proxy also handles the translation from host names to IP addresses. As a result, the local HOSTS file may not be queried.

To configure Internet Explorer to use the local HOSTS file, please go through the following sequence: Start Internet Explorer -> Tools -> Internet Options -> Connections. Double-click your connection in the list labelled "Dial-up and Virtual Private Network settings. Check the box for "Bypass proxy servers for local addresses".
Note that this fix only applies to users running Internet Explorer using a connection configured to use a HTTP proxy.


  1. The HOSTS file example above uses IP addresses for Google and Yahoo, valid at the time of writing but they may change in future.
  2. It is not possible to use wildcards to block a range of servers, such as *
  3. The HOSTS file can only map host names to IP addresses. Mapping an IP to another IP or a host name to another host name is not possible.
  4. The claims made here about the HOSTS file refers to Microsoft Windows platform.


Hi there, after reading this amazing paragraph i am also glad
to share my familiarity here with friends.

# 27 Aug 2014, 22:01

windows 7 key generator writes

0 thumbs

Hi, i think that i noticed you visited my site so i got here to return the choose?.I am attempting to find things to
improve my website!I assume its adequate to make use
of some of your ideas!!

# 27 Aug 2014, 23:29

Nice post. I was checking constantly this weblog and I'm impressed!
Extremely helpful information specially the ultimate section :) I deal with such information a lot.
I used to be seeking this certain info for a very lengthy time.
Thanks and best of luck.

# 28 Aug 2014, 5:01

Corel Draw X7 serial key writes

0 thumbs

You've made some decent points there. I looked on the
web for more information about the issue and found most people will
go along with your views on this site.

# 1 Sep 2014, 2:30

office 2007 product key writes

0 thumbs

Hello, its fastidious post regarding media print, we all be familiar with media is
a wonderful source of information.

# 1 Sep 2014, 7:49

Leave a reply