How can I add localhost to my etc/hosts file/

Discussion in 'Mac OS X Lion (10.7)' started by oxband, Jun 19, 2013.

  1. oxband macrumors 6502

    Sep 10, 2009
    So, for months and months, my computer, every 12 seconds or so in the console, shows this: rpc.lockd: can't contact statd, 100024 RPC: Unknown host

    I want to resolve this. It cant be good.

    Someone on the Apple Disccussion proposed this as a solution: "sounds kinda like loop back is missing from your etc/hosts file? Add localhost if its not at the head of the file and see if it fixes the problem."

    I want to try that but I have no idea how to. Can someone explain this to me?
  2. MacUser2525 macrumors 68000


    Mar 17, 2007
    You would open (it is in the Utilities folder) then type in and hit enter key sudo nano /etc/hosts again type in then hit enter key your password when asked. The file will now open for editing where you can add the line you desire. To save and exit use the control and x keys at the same time confirming you wish to save the file when asked. My /etc/hosts as it by default from Apple in Mountain Lion for your reference.

    MacUser2525:~$ cat /etc/hosts
    # Host Database
    # localhost is used to configure the loopback interface
    # when the system is booting.  Do not change this entry.
    ##	localhost	broadcasthost
    ::1             localhost 
    fe80::1%lo0	localhost
  3. benwiggy macrumors 68020

    Jun 15, 2012
    If you are unfamiliar with the Terminal, I would recommend using the free text editor, TextWrangler for modifying system files.
    It lets you browse hidden files in its open file dialog, and handles correct permissions/authorisation.

    However, I am surprised that your hosts file got modified without your knowledge.
  4. chown33 macrumors 604

    Aug 9, 2009
    Sailing beyond the sunset
    The first step should be to look at your hosts file. If it's correct, then it doesn't need editing. This is the "Look before you leap" principle.

    Copy and paste this exact command-line into a Terminal window:
    cat /etc/hosts
    Compare the output with the output posted in post #2.

    If yours looks the same as what MacUser2525 posted, you don't need to edit or change anything, and the guess that was made in that Apple Discussion is wrong.

    If yours doesn't look the same, then copy and paste the complete output from the Terminal window into a reply posted here.

Share This Page