Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

model500

macrumors newbie
Original poster
Hello I am trying to ban www.facebook.com (too distracting!) from my mac at work by adding:

127.0.0.1 facebook.com

at the bottom of the text on the file /etc/hosts. I have already added read and write for everyone in Sharing and Permissions having clicked get info on this file. Despite having this in place I still can not save the changes I make to the file - even though it clearly says I have read and write permissions.

I have been able to do this in my XP Boot Camp but it not in OS X. I am running 10.5.4 having upgraded it from Leopard.

http://www.flickr.com/photos/28778651@N07/2685829942/
 
Hello I am trying to ban www.facebook.com (too distracting!) from my mac at work by adding:

127.0.0.1 facebook.com

at the bottom of the text on the file /etc/hosts. I have already added read and write for everyone in Sharing and Permissions having clicked get info on this file. Despite having this in place I still can not save the changes I make to the file - even though it clearly says I have read and write permissions.

I have been able to do this in my XP Boot Camp but it not in OS X. I am running 10.5.4 having upgraded it from Leopard.

http://www.flickr.com/photos/28778651@N07/2685829942/

That's because the whole directory is admin permissions, and textedit is running with your current user perms.

you can use the Go menu in finder to get to /private/etc/ and drag the hosts file to the desktop, edit and save it back to the desktop in textedit, then drag it back to /private/etc/
a dialog will come up asking if you want to overwrite the original and then another asking for your admin password.

or you can open terminal, type "sudo pico /private/etc/hosts it'll ask for you admin password, then you can edit the file in pico, save by hitting control-o and exit by hitting ctrl-x.

You may have to return the permissions to what they were before editing too, it's best not to alter the permissions in those directories.
 
Open Terminal.

Type cd /etc

Type sudo nano hosts

Type your password

Edit File

Hit Ctrl + O to save

Hit Ctrl + X to quit

Done.

Edit : bah didn't see the explanation above 😛.
 
I have made the changes and they can be seen on the host file. However I still have access to the site from which I am trying to ban myself. Is there anything else I need to do exceot 127.0.0.1 (tab) www.facebook.com
 
Try banning the IP address:
69.63.178.11

It might not be the same for you depending on your location so run

ping facebook.com
in terminal (press CTRL + C to stop)
you may also need to try www.facebook.com
for me it has an IP of 69.63.184.15
 
Funny how each has his/her own method for editing the hosts file. Mine's: "sudo vi /etc/hosts".

Alternatively, perhaps the OP could try blocking facebook using Parental Controls.
 
I have made the changes and they can be seen on the host file. However I still have access to the site from which I am trying to ban myself. Is there anything else I need to do exceot 127.0.0.1 (tab) www.facebook.com

What is the search order or name resolution? Is it files then DNS or DNS then files? If it is looking at /etc/hosts last then it's not going to work. Take a look in /etc/resolv.conf
 
I have made the changes and they can be seen on the host file. However I still have access to the site from which I am trying to ban myself. Is there anything else I need to do exceot 127.0.0.1 (tab) www.facebook.com

That should work. I added "127.0.0.1 www.facebook.com" to mine and it started blocking it immediately.

Did you correct the permissions on the hosts file? They should be system read & write, wheel read only and everyone read only.

Also, if you're editing in textedit, make sure it didn't ad .txt as the file extension, it won't show unless you have show all file extensions set in finder prefs. Get info on the file and check under Name & Extension, uncheck Hide extension.
 
Going the hosts file route would not have been my first choice for blocking URLs, but anyway there should already be this line for the loopback:

127.0.0.1 localhost

...why not add to that line rather than creating a new one? E.g.:

127.0.0.1 localhost www.facebook.com

In any case, with the above method if you have a webserver running, facebook's URL should take you to your local webserver page.
 
Also, if you're using Tiger or Leopard, after you edit the hosts file, it's necessary to restart lookupd. This can be done from the Terminal:

Code:
killall -HUP lookupd
 
Also, if you're using Tiger or Leopard, after you edit the hosts file, it's necessary to restart lookupd. This can be done from the Terminal:

Code:
killall -HUP lookupd

nope you don't have to restart in tiger or leopard, I've been using hosts to block ads since 10.2, it used to be a lot more complex, but now it picks up changes as soon as you save.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.