Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I edited my localhost file to block the last two websites (text in bold) but mozilla still connects to them. For example: when i'm trying to go to it switches me to this search black friday thing...can someone look and tell me what I did wrong and how to correct it so that it works. Thanks

# 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
# space.
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
# For example:
#          # source server
#              # x client host

# localhost name resolution is handled within DNS itself.
#       localhost
#   ::1             localhost

share|improve this question
localhost is intended to serve resolution of local names, not to do site blocking. In fact, one could still go to the banned sites using the numerical IP. The proper way to do such a blocking is by means of some firewall, such as IP Tables. – zakmck May 21 '12 at 18:02

That's the wrong format. You cannot use URLs in hosts only machine names.

Eg. this entry would be OK:

which would redirect all connections for to localhost (not just HTTP, everything).

It also relies on there being nothing running on localhost to respond, eg. if you are running IIS, then it will respond (possibly with an error) to the redirected requests.

share|improve this answer
Also, sometimes you have to clear the DNS cache with ipconfig /flushdns. +1 – jmort253 Apr 9 '12 at 8:07

You can use WWW but not the http:.

We are telling our local machine that Yahoo actually exists on the local machine. Any request for will be directed to the local machine and therefore effectively blocked. You could also use the IP of another website if you wanted to be creative.

Let’s take a closer look at a URL
http:// defines the transfer protocol in this case Hyper Text Transport Protocol; this is the standard for viewing websites. Another common protocol is ftp:// for file transfer.
www is the host is the domain
.com is further classified as the TLD (Top Level Domain)

A HOSTS file entry will disregard the transfer protocol so it isn’t needed. However, the host does play an important role. A webmaster may choose to define a host for his/her website. WWW has become the universal standard for the default host. It is just as common to define a site with no host as well. This means that as far as DNS goes & are two totally different sites, even though they resolve to the same place. Because of this to effectively block the site, you must also block all hosts. This would usually mean:

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .