editing mac osx 10.4 hosts file

Posted on 2009-02-10
Last Modified: 2013-11-23
Hi,  I've been trying in vain to edit the mac osx hosts file.  I've tried the following so far:

edit the host file in /etc:  I put in the ip address and the website address all the way at the bottom of the file and save it.  Then I do the following as instructed on several websites:

$ sudo niutil -create . /locations/lookupd/hosts

$ sudo niutil -createprop . /locations/lookupd/hosts LookupOrder FFAgent DNSAgent
$ sudo killall lookupd

After all this, i even restarted the machine, and it still doesn't work.  Any ideas?
Question by:ITatES
    LVL 39

    Expert Comment

    1. Can you provide a little more detail on what you're trying to achieve?

    2. Can you supply the line you are adding to the hosts file? Obfuscate if necessary

    Author Comment


    I add that line to the hosts file and save it.  It doesn't work when typing in in the browser.  I read on a couple of websites that osx doesn't go to hosts file by default so you need to modify the lookupd for it to do that, and hence i tried the commands listed above.  Still it doesn't work.
    LVL 39

    Accepted Solution

    OK ..

    There should be no need to do anything other than edit the /etc/hosts file in OSX 10.4 (I think those tips were for OSX 10.1& 10.2)

    You need to be a little careful with the hosts  file as it is locked to prevent standard users editing it .. you must also take care NOT to use anything other than a plain text editor like TextWrangler or a terminal based editor pico, vi etc. as the characters and line-endings can become affected and the host file will cease to function.

    How did you edit the hosts file?  Do you have a backup you can restore and start again using the Terminal
    In Terminal enter
    sudo pico /etc/hosts
    also make sure that you have a TAB between the IP address and the URL .. not a single space .. if necessary duplicate a line above and edit it
    It should look more like

    LVL 53

    Expert Comment


    Author Comment

    strung, I went to that exact same site and tried the exact same thing.  

    Sullivan, I had a tab before, but that didn't work so I changed it to a space.  
    I saved the hosts file by first saving it on desktop and then replacing the one in /etc by the new saved one.  When I replaced, it asked for the admin password to overwrite and i entered it.
    LVL 39

    Expert Comment

    What program did you use to edit the hosts file?  If it was TextEdit on OSX you may have corrupted the file format and the hosts file will not work.

    Can you restore a clean original of the hosts file and start again using the Terminal commands I provided?


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Suggested Solutions

    If you other experts are anything like me you are always looking into and testing out new features. While I was doing some research one day I ran across an app that I installed on my Mac and used as a security system. Mac OS X: SecureHome uses your …
    Information security is a multi-billion dollar industry. Just as lucrative is the black market industry which trades stolen identities, credit card numbers and software exploits all over the world. Nothing is hack-proof. The best one can do is make …
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now