We help IT Professionals succeed at work.

editing mac osx 10.4 hosts file

ITatES
ITatES asked
on
Medium Priority
1,831 Views
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?
Comment
Watch Question

Eoin OSullivanConsultant
CERTIFIED EXPERT

Commented:
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

Commented:
yes,

192.158.1.24 www.blahblah.com

I add that line to the hosts file and save it.  It doesn't work when typing in www.blahblah.com 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.
Consultant
CERTIFIED EXPERT
Commented:
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
192.158.1.24         www.blahblah.com


Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
CERTIFIED EXPERT

Commented:

Author

Commented:
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.
Eoin OSullivanConsultant
CERTIFIED EXPERT

Commented:
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?

Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.