Edit HOSTS file, it's Empty!

Discussion in 'macOS' started by haraldstoll, Sep 8, 2010.

  1. haraldstoll macrumors newbie

    Sep 8, 2010
    I need to add something to the HOSTS file, here is the error message that appears when I try to log in.

    TextEdit[190:c0b] *** CFMessagePort: bootstrap_register(): failed 1100 (0x44c) 'Permission denied', port = 0x4403, name = 'com.apple.TextEdit.ServiceProvider'
    See /usr/include/servers/bootstrap_defs.h for the error codes.

    Using: sudo /Applications/TextEdit.app/Contents/MacOS/TextEdit /etc/hosts

    It does open the file, but it is empty. Should it be empty? I can not save it after editing it.

    But, if i use sudo open -t /etc/hosts OR $ sudo nano /private/etc/hosts

    It doesn't give me any error, and it also opens the HOSTS file. But its empty!

    Im using MAc Osx 10.5

    Any ideas of what's going on?
  2. LPZ macrumors 65816

    Jul 11, 2006
    Here's what I have in /etc/hosts on my 10.5.8 system:

    # 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
    Did you inadvertently wipe yours? I wouldn't consider trying to invoke TextEdit from the command line. :eek:
  3. GoCubsGo macrumors Nehalem


    Feb 19, 2005
    I would also not invoke text edit from a command line. I'd log in as root and open the host file there. What are you trying to add?
  4. haraldstoll thread starter macrumors newbie

    Sep 8, 2010
    I wanted to add a foreign server as being a local one.
    Meaning, " www.google.com" (example)

    The file hasn't been changed in the past. I have done the trick on a windows machine.

    Should i use the editor outside the terminal? Will i then have admin rights?
    Can i actually find the file using explorer?

    Please advise me on the best course of action to add this line to the HOSTS using Mac.
  5. LPZ macrumors 65816

    Jul 11, 2006
    At Terminal command line, could do

    sudo nano /etc/hosts

    Then type in the line you want, press control-o to save and control-x to exit.

    You can then use the chown command to change ownership if you wish.

    Are you sure you know what you're doing?
  6. belvdr macrumors 603

    Aug 15, 2005
    No longer logging into MR
    Alternatively and (arguably) way simpler:

    echo www.google.com | sudo tee -a /etc/hosts
    This will append that line to the bottom of /etc/hosts.
  7. LPZ macrumors 65816

    Jul 11, 2006
    Yes, but since the OP had mentioned nano earlier ...

Share This Page