General Question

zarnold's avatar

Malfunctioning /etc/hosts file in OS X?

Asked by zarnold (695points) May 12th, 2008

I’ve edited my /etc/hosts file to prevent connections from my computer to several time-wasting sites, but I’ve found that only about half of the specified websites are actually blocked. Suggestions? Thanks!

Observing members: 0 Composing members: 0

7 Answers

jrpowell's avatar

What did you use to edit the file? Perhaps what you used is fucking up the line breaks.

zarnold's avatar

could be; the only editor that allowed me the necessary access was nano.

giovani's avatar

The /etc/hosts file is not designed for “blocking” access to hosts. While it is used for this purpose occasionally, there are often better, more robust ways of doing so, as /etc/hosts can only be used to “redirect” requests to a local/nonexistant IP address.

If you could paste the relevant lines that are not giving you the desired effect, and what exactly you’re doing to test (visiting a given url in a browser, or something else) that would be helpful in diagnosing the problem. This isn’t for ad-blocking by any chance, is it?

sferik's avatar

Try flushing your DNS cache…

In Mac OS X 10.4 and earlier type:
sudo lookupd -flushcache

In Mac OS X 10.5 and later type:
sudo dscacheutil -flushcache

zarnold's avatar

These are the malfunctioning lines (beneath the localhost, etc entries):

sferik's avatar

Looks right to me. Did flushing the DNS cache work?

zarnold's avatar

it did seems to work now, but I’ll probably take giovani’s advice and look for a browser-based solution instead.

Thanks everyone!

Answer this question




to answer.

This question is in the General Section. Responses must be helpful and on-topic.

Your answer will be saved while you login or join.

Have a question? Ask Fluther!

What do you know more about?
Knowledge Networking @ Fluther