Home » Questions » Computers [ Ask a new question ]

How did I manage to mangle my Mac OS X hosts?

How did I manage to mangle my Mac OS X hosts?

A while ago I set reddit.com to 127.0.0.1 in my hosts, because it was way too much of a time sink. I don't remember exactly how I set it - I know I had some trouble with it and tried a few different things before I found the "right" method, so I might have done something weird.

Asked by: Guest | Views: 171
Total answers/comments: 2
bert [Entry]

"It sounds like you may've created the host entry in DSLocal, rather than /etc/hosts. To find out, run:

dscl /Search -read /Hosts/reddit.com

It should come back with something like this:

AppleMetaNodeLocation: /Local/Default
IPAddress: 127.0.0.1
RecordName: reddit.com
RecordType: dsRecTypeStandard:Hosts

See the AppleMetaNodeLocation? That tells you where it's getting the info from. If it says /BSD/local, it's in /etc/hosts; if it says /Local/Default (which I suspect it will), that's the default local directory node, aka DSLocal. If it says <dscl_cmd> DS Error: -14136 (eDSRecordNotFound), then I have no idea what you've done.

Anyway, assuming the entry is coming from DSLocal, it's fairly easy to remove:

sudo dscl /Local/Default -delete /Hosts/reddit.com"
bert [Entry]

"It seems that you need to run

sudo niload -v -m hosts . < /etc/hosts

after updating your hosts file if you want the changes to take."