You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

/etc/hosts file not being used in Snow Leopard

I have added several hosts to my /etc/hosts file in Snow Leopard. In Leopard (10.5), once I saved the /etc/hosts file, the hosts were available and usable. In Snow Leopard, it's like this file is never read or used. I cannot get Snow Leopard to use these entries at all in Terminal. I use this "local DNS" style feature every day at work to connect to computer systems on the corporate LAN.

In past releases, you had to import these entries into NetInfo; however, as of Leopard, my understanding is that NetInfo is gone (or, at least, niload is).

Am I missing a new step in Snow Leopard? I have tried logging out and back in, and I've restarted the computer many times since the entries were made.

Any help would be much appreciated.

MacBook Pro Core 2 Duo, 2.66GHz, 4GB RAM, 320GB HDD, Mac OS X (10.6.1)

Posted on Sep 16, 2009 10:24 AM

Reply
Question marked as Top-ranking reply

Posted on Sep 16, 2009 10:33 AM

/etc/hosts works fine in snow leopard. make sure you use the correct syntax when editing it and also make sure that it has correct permissions. it should be owned by the system and have 644 permissions.
24 replies

Oct 21, 2009 7:09 PM in response to Sharp-man

I have to add my two cents to this frustrating conundrum. When Snow Leopard first came out I used the old /etc/hosts trick to block a number of ad servers before finding more efficient ways of doing that. When I deleted the no longer needed lines of ad servers from the /etc/hosts file, some websites continued to be blocked (though it appeared that not all did). This is after using dnscache -flushcache and several reboots.

Here's the odd thing: when I use the dscacheutil -q host -a name hostname.com command to test the sites that I can't get to, they resolve to their proper IP. When I test sites I've included in the hosts file, they correctly resolve to 127.0.0.1. So it appears that, while Snow Leopard is correctly using the hosts file, there's something else on my computer that is blocking the websites, across all browsers (so it's system wide). I've ruled out my router (since other computers on the network can access these same sites), IPv6 (turned it off), and any adblocking software.

I searched a little on Google and seem to be encountering a number of people who have similar issues within Snow Leopard. Any thoughts?

Oct 22, 2009 11:29 AM in response to Tex-Twil

Tex-Twil wrote:
$ dscacheutil -q host -a name facebook.com
name: facebook.com
ip_address: 127.0.0.1


When I open FF or Safari and type facebook.com it works


Just as a clarification, to see the "blocking" you have to explicitly enter "http://facebook.com" into the URL bar.

If you just enter "facebook.com" most browsers will then do a Google search for the site and then convert it accordingly rather than just prefix the address you enter with "http://."

So for example, if I watch Firefox closely, if I enter "facebook.com" in the URL bar, it will look up the URL and will load "http://www.facebook.com", and since "www.facebook.com" is a different host, it will not be blocked.

Mar 6, 2010 7:29 AM in response to stackless python

hi,

my hosts file looks like this:

##
# 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:8111 ci

(new line at the end, tab as a separator)

after flushing the DNS (sudo dscacheutil -flushcache) and 'traceroute ci' I get 'unknown host ci' message. am I missing something?

Message was edited by: vanjan

Mar 6, 2010 4:20 PM in response to vanjan

vanjan wrote:
##
# 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:8111 ci

(new line at the end, tab as a separator)



I think you need to change "127.0.0.1:8111 ci" to "127.0.0.1 ci"

/etc/hosts file not being used in Snow Leopard

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.