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've tried adding the following line to my hosts file in Windows 7:

The hosts file is located in:


The idea is to block access to the New York Times website (and others).

Even after re-starting the machine, this does not block access to the site. Why not?

share|improve this question

migrated from Aug 7 '11 at 11:54

This question came from our site for professional and enthusiast programmers.

The site is, it's a different host name.

share|improve this answer

If the browser is configured to use a proxy, then it likely doesn't matter what's in the HOSTS files.

share|improve this answer
Moreover, using a proxy is the far better way to go about achieving the actual goal at hand, in any event. – JdeBP Aug 8 '11 at 0:31

(Normally a restart isn't required for changes to the local HOSTS file to take effect.)

Your blocking technique may work better if you include both hostnames (and you can place more than one on a single line, or make several entries for the same IP address across multiple lines), one with the "www." prefix and one without (just as I'm showing here, except that I'm using "" instead):

The reason that blocking doesn't work as you expected is that the HOSTS file is very literal in the way it handles things, and you're probably using the "www." prefix variation of the hostname which I'm also assuming that you didn't define [since your example shows only one hostname without the "www." prefix].

If you were using a DNS server instead, then you could set up a zone for "" and "" would be included automatically (this is due to the hierarchial nature of DNS). The HOSTS file, on the other hand, will allow you to override IP addresses only for the hostnames you specify therein.

When resolving a hostname to an IP address, your computer normally consults the local HOSTS file first, followed by any local cache, and then queries DNS after that. This is done to preserve bandwidth, and it's very effective.

For a handful of computers, the local HOSTS file can be easy to manage, but for a large number of computers it's usually easier to set up a DNS server (with the zones you want to block added to resolve to nothing, or, or even an intranet server) and configure all the computers to use it.

share|improve this answer

I would recommend using browser plugin like AdBlock Plus to do this. It is a cleaner solution, ie. more likely to work, because AdBlock is designed to block elements and URLs within pages, whereas hosts file is not meant for use like this. Adblock Plus is available to both Firefox and Chrome, which are very much recommended for security reasons, too.

share|improve this answer
+1 for saying that the hosts file is not the way to go about achieving the end goal. You could also mention the Proxy Auto-Configuration script way of achieving the intended goal. – JdeBP Aug 8 '11 at 0:33

There should be not a space but a tab between IP and host name:>
share|improve this answer
Are you sure this matters? On other systems there is no difference between space and tab in a hosts file. – Raffael Aug 7 '11 at 12:03
@Raffael: It doesn't matter. Spaces and/or tabs are acceptable delimiters. – Randolf Richardson Aug 12 '11 at 3:33
@Randolf, Raffael: That's the issue I ran by myself. Space was not working until I switched to tab – abatishchev Aug 12 '11 at 4:38
I just tested this with a space in 64-bit Windows 7 (with Service Pack 1 and other updates installed), and it worked just fine. It also worked equally well with a tab. Removing the entry resulted in my temporary hostname not resolving (as expected). Is your editor inserting something different for the space, such as a unicode character instead of ASCII character #32, perhaps? This is odd, as it should work with spaces and/or tabs. – Randolf Richardson Aug 12 '11 at 4:43
@Randolf: That's exactly how I had it in my mind too. But I am using more Linux than Windows so I was not 100% sure. Thanks for the confirmation. – Raffael Aug 12 '11 at 7:15

You must log in to answer this question.