Why is Safari ignoring my /etc/hosts file? I added some domains to block (127.0.0.1 mydomain.com) to my /etc/hosts file and for some reason, Safari seems to be ignoring them. 

I have tried:


disabling Safari extensions, 
clearing the cache (sudo dscacheutil -flushcache), 
restarting Safari and the Mac altogether. 


Chrome respects the /etc/hosts changes, but Safari does not. Attached is a sample of my /etc/hosts file. 

I am running Safari 6.0.4 with Mountain Lion 10.8.3

Any ideas?

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1       localhost
255.255.255.255 broadcasthost
::1             localhost
fe80::1%lo0     localhost
127.0.0.1       facebook.com
I had a slightly different version of the same problem, and thought I'd mention what worked for me.

I develop websites.  To do that, I have a complete copy of each site running on my local network.  When I wish to work locally, I have always just added an entry for "example.com" to my local /etc/hosts file, and that has always overridden DNS, making it possible for me to access the local copy of the website in any browser, including Safari and Firefox.  I can work without affecting the actual live site, then upload changes when they're complete.

Recently, however, this technique stopped working for both Safari and Firefox, but not for Chrome, so for a while I was limited to using Chrome for local development.  I searched google and tried all the suggested fixes -- CR at the end of the hosts file, only one entry per line, various Firefox configuration changes using "about:config", etc.  Nothing worked.

Then I tried this simple thing:  in addition to putting the IPV4 version of the address in the /etc/hosts file, I also put the IPV6 version.

Before:

10.0.1.23       example.com


After:

10.0.1.23       example.com
0:0:0:0:0:FFFF:0A00:0117        example.com


As soon as I added the IPV6 entry, both Firefox and Safari started hitting the correct (local) server.

There are various websites that will translate IPV4 addresses to IPV6; just do a google search on "ipv4 to ipv6".