• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1814
  • Last Modified:

editing mac osx 10.4 hosts file

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?
  • 3
  • 2
1 Solution
Eoin OSullivanConsultantCommented:
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
ITatESAuthor Commented:
yes, 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.
Eoin OSullivanConsultantCommented:
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         www.blahblah.com

Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

ITatESAuthor 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 OSullivanConsultantCommented:
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?

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now