osx - Hosts file cannot be found, max OS X

08
2014-07
  • Tristen

    When I went restored my iPhone through iTunes I got an error 3194. I followed the instructions on the Apple site that tells me to edit my hosts file.

    I followed the instructions and opened sudo in terminal, the box was empty. The top did say I was in File: /private/etc/hosts, but the file was empty. Then I tried go to the folder: /private/etc/hosts and then it says "The folder cannot be found."

    Am I doing something wrong? Did something get deleted?

  • Answers
    Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

    Related Question

    osx - How did I manage to mangle my Mac OS X hosts?
  • alex_c

    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.

    Now, no matter what I do, I can't un-set it or set it to something else - it's somehow "stuck" on 127.0.0.1.

    $ sudo nano /etc/hosts
    Password:
    

    I add these two lines:

    208.96.53.70 reddit.com
    208.96.53.70 reddit2.com
    

    Save, exit, then:

    $ dscacheutil -flushcache
    $ ping reddit.com
    PING reddit.com (127.0.0.1): 56 data bytes
    $ ping reddit2.com
    PING reddit2.com (208.96.53.70): 56 data bytes
    

    Same thing if I don't specify reddit.com at all.

    What am I missing?? I don't have any other entry for reddit.com in my hosts file. It's not a router or ISP issue - other computers on the same router are fine. Where else could it be defined?

    For the sake of completeness, I cleaned everything out of my hosts, and it contains only the following:

    ##
    # 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
    

  • Related Answers
  • Gordon Davisson

    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
    
  • Tyler

    try

    dscacheutil -flushcache
    ping reddit.com
    

    and report back.

  • Sopoforic

    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.