# blocking individual web sites on Safari



## Istorik

I'd like to be able to block individual websites, not whole categories, on my iMac running OS X and Safari. I called Apple but were unable to help me. The commercial programs I've looked at appear designed to block whole categories. On other on-line forums, I've seen detailed descriptions on how to block indivdual sites within a Windows format, but not for the iMac. Suggestions greatly welcome. 

I am not a computer person but can follow precise directions. Thanks, Dan


----------



## POADB

Hi Dan, welcome to TSF.

Use the hosts file :smile:
It's just like in Windows, except it's a little trickier to access.
Use Finder to search for the application *Terminal*.
In there type: *sudo pico /etc/hosts*
Enter your root password.
Use the arrow keys to move down to the bottom line and then type:

*127.0.0.1 www.thesiteyouwanttoblock.com*

There is a space between 127.0.0.1 and www.

User *Ctrl+X* to exit and *Y* to Save.

Then type *lookupd -flushcache*

Quit the Terminal and restart Safari.


----------



## Istorik

I found the Terminal application. When I double clicked on it, a small pop up entitled Terminal--bash--80x24 opened up. It listed the last login (not by me), Welcome to Darwin!, then the name of my computer and my name followed by a dollar sign. 

I entered in sudo pico /etc/hosts and it indeed asked for my password. I gave the administrative password, but it did not accept it. Is the root password different from the admin password?

Thanks again for your patience, Dan


----------



## sinclair_tm

Yes it is. The root password is something that you must enable, and then set. In order to tell you how to do so, I need to know what version of OS X you are using, as there are some differences depending on the OS.


----------



## Istorik

It is Mac OS X Version 10.4.11. There were some scary messages when I entered the terminal application. I don't want to scramble the brains of my beautiful iMac.

Thanks,
Dan


----------



## sinclair_tm

it always warns you like that the 1st time you use sudo. goto your utilities folder and open the app called netinfo manager. goto the menu security and choose authenticate. here you will have to use the admin name and password. once it accepts that, goto the same menu and select enable root user, and give it a really good password. now you can use sudo from the terminal.


----------



## Istorik

Bear with me, but I did establish a root password, but once I was in sudo, it would not accept the password. I exited and changed the password and tried again. Still no dice. 

One observation/one question: 

1. When I type in the password within Sudo, the cursor does not move. It doesn't show what I'm typing nor does it offer a string of ********. Is there some special protocol for entering a root password?

2. Should there be a space between pico and /etc. Couldn't tell from the original post. I tried it both ways. They both got me to the password stage......

Suggestions?
2.


----------



## sinclair_tm

yes, there should be a space. as for the password, no there will be no feedback at all with sudo. remember, use only numbers and lowercase letters for the root password, about 8 characters long.


----------



## Istorik

I finally got in to sudo, but using the regular password, not the root password. Anyhow, I proceeded as directed, and entered the web-site I want to block. I only entered one, but if I wanted to enter several, would I also use 127.0.0.1?


I did pause when I got to 

lookupd -flushcache

The cursor at that time was at the end of a line of "DOS" text that said File name to write /etc/hosts

Is that where I was supposed to type lookupd -flushcache or on a different line.

Also, as I exited terminal, there appeared to be several intermediate messages/stages. Again, I just don't want to do something that I can't reverse.


----------



## sinclair_tm

Okay, after opening the Terminal, typing in the sudo line, entering you password, you are now in the host file. you want to put in the 127.0.0.1 for every site you wished blocked. then you do the control-x, and at the bottom it will ask you if you want to write the file, which is where you were. that is where you push the "y" key for yes, you want to write. then the terminal window should look like it did when you first opened it, only you'll now see thee sudo line you typed. That is where you type the flush cache line.


----------



## POADB

POADB said:


> Hi Dan, welcome to TSF.
> 
> Use the hosts file :smile:
> It's just like in Windows, except it's a little trickier to access.
> Use Finder to search for the application *Terminal*.
> In there type: *sudo pico /etc/hosts*
> Enter your root password.
> Use the arrow keys to move down to the bottom line and then type:
> 
> *127.0.0.1 www.thesiteyouwanttoblock.com*
> 
> There is a space between 127.0.0.1 and www.
> 
> User *Ctrl+X* to exit and *Y* to Save.
> 
> Then type *lookupd -flushcache*
> 
> Quit the Terminal and restart Safari.


I thought my instructions were clear.... :4-dontkno


----------



## Istorik

Gents,
Got it. I just needed to "return" out of that box to the $ line, and then enter in the flush command. It now works.

Many thanks for your patience.


----------



## POADB

No problem Istorik.


----------



## Istorik

One follow up query: Is it possible to add something to the website address in the terminal utility to block the whole domain? That is, not just www.ebay.com but all the websites that start with that. Some sort of /* code?


----------



## sinclair_tm

stopping ebay.com should kill all pages of it, or so i'd think. or if that doesn't work, find the ip address of ebay and block that.


----------



## POADB

If you put in http://www.ebay.com - that domain will be blocked.
I think you might need to add https://www.ebay.co.uk too, for the secure server - and any other server before the ebay.com domain. (such as www2)


----------



## billdozzer

How do you unblock the web site after?


----------



## sinclair_tm

Please start a new thread and give detail about your problem.


----------



## MaoDaAmargura

I found the above instructions very useful, with this note: In Snow Leopard (OS X 10.6.x) lookupd has been replaced with (or renamed to) dscacheutil. Thanks for the help.


----------



## Alia2

I found this page and forum with a search on blocking individual websites. 

Trying every step above, I was only confused at the last stage when asked to save under another file name. I hit Y, and left Terminal, quite and re-started Safari.

And my blocked website was still perfectly available. 

I cleared the cache, and instead of the last post on using dscacheutil instead of lookupd, I opted to go with the original lookupd. Still the website is available. 

I don't know if this has any bearing on the matter, but when I typed my root password in, this was rejected. I typed my administrator password in, and everything went forward from that point.

Previously I had found this site, but found it lacking detail: http://osxdaily.com/2007/03/19/block-access-to-specified-sites-by-modifying-etchosts/

Not even the www is included, the Y, or anything -flushcache. (I assume there is a space between dscacheutil and -flushcache?)

Can anyone help with what I might be missing here?

Thank you in advance,
Alia

N.B. I'm no computer expert by a long shot; just attempting to follow clear instructions and hoping it will work. I'm trying to block a game site for my sons, that's all.


----------



## sinclair_tm

If this is for another user, the best thing would be to create for them their own account (be sure to change the password on all other accounts that they may know) and then as the admin, you can turn parental controls on, and then there will be an option to you to list websites that they can not goto from their account.


----------



## Alia2

Thanks, but I tried that. There is one laptop here, as he's at university and comes back, but uses my laptop. For work, I have to leave my admin account on at all times (Skype incoming calls, email, etc.) and the option to close the account for him to have an alternative is not a consideration.

I tried that, and lost several important calls. So I cannot use a second account, which fails to see missed Skype calls. (I realise the Skype account can be opened on a second account, but this means professional calls are answered, or ignored, by a teenager.)

I just want to be able to use the function that I know is available, as it applies to this laptop and this account at all times. It's an ideal solution...if I could get it to work!

Thanks.


----------



## sinclair_tm

If he is using your laptop when calls come in, then he's answering them anyway is the thought going through my head. But I don't know what to tell you. I do not do site blocking, I just practice self control and not goto site that I shouldn't. I'm not sure how OS X 10.6 handles network calls, so I don't know where any other host files would be that you need to edit to block sites. Perhaps someone else reading this thread does know and can post.


----------



## argoneus

Thanks a lot! POADB! This solution works perfect on my Mac. Almost immediately. Now I'm putting effort to get away from youtube addiction. Guess My life would suck for a while.


----------



## shoichi

I follow all the steps and at the end, the websites are still not blocked. 

I think where I may be doing something wrong is towards the end

when I put the website address as "127.0.0.1 www.perezhilton.com" I press Control + X, then I press Y. and where it says "File Name to Write: /etc/hosts" I put 'lookupd -flushcache', with space between the word 'lookupd' and the symbol '-'. then i go to Terminal and click on choose Quit Terminal. 

dont i have to save any things I add to Terminal? I looked under the Terminal and File tab but couldn't find a Save option. 

I tried to put the 'lookupd -flushcache' phrase with and without a space in front of ' /etc/hosts and it still does not work.

I set up a new root password and tried logging onto terminal with that but after a few tries and getting rejected, i tried with my adming password and was accepted. 

I hope I've explained my problem in a way that it is clearly understood by you. 

many thanks in advance


----------



## sinclair_tm

shoichi said:


> and where it says "File Name to Write: /etc/hosts" I put 'lookupd -flushcache', with space between the word 'lookupd' and the symbol '-'.


In reading this it sounds like you are making the name 'lookupd -flushcache'. that is a command that you do after you are all done in vi with editing the hosts file. When you get "File Name to Write: /etc/hosts", you should just hit the return key. It may ask about over writing, you type Y and return. After it is done and you are back to a command prompt, then you type 'lookupd -flushcache'.


----------



## shoichi

sinclair_tm said:


> In reading this it sounds like you are making the name 'lookupd -flushcache'. that is a command that you do after you are all done in vi with editing the hosts file. When you get "File Name to Write: /etc/hosts", you should just hit the return key. It may ask about over writing, you type Y and return. After it is done and you are back to a command prompt, then you type 'lookupd -flushcache'.



i seem to get the process now. i blocked a few sites and they don't load anymore when i try to open them

but some sites, do not get blocked. 

i noticed those are the ones that start with http:// rather than www.

i tried both options, putting http:// and also www. but nothing worked. i can still reach the sites and they open

any suggestions for this?

thank you by the way. you've already helped ALOT. truly appreciate it


----------



## sinclair_tm

Try it without http:// or www. in the front.


----------



## kcharris

Okay... I have read this post about 120 times. I am having similar problems to Alia2 here. I have followed the instructions. The site I want blocked still comes up too. What am I doing wrong here?


----------



## sinclair_tm

Okay, the instructions were written for an older version of OS X. Apple changed a lot of things with 10.5, but how to do this now with the newer OS, I don't know. Have you tried using a managed account yet?


----------



## kcharris

I could set up an additional account and put parental controls on there but I am the only one using this computer. There is one site I want blocked. I guess I just won't visit this site anymore if there isn't a method to just block one site.


----------



## kostoglotov

Hi Sinclair_tm.
Can I bother you a bit with that problem as well? It works exactly as you describe to the point when it says: "File Name to Write: /etc/hosts". Here I just press enter and then "lookupd -flushcache" and it says "command not found" (as follows)

Macintosh:~ alex$ lookupd -flushcache
-bash: lookupd: command not found

Any Idea?
Cheers


----------



## sinclair_tm

Please don't bring up old threads. Post a new one, and if you feel it'd help, add a link to the old one for reference.

Seeing that you are using OS X 10.6, it seems that lookupd has been replaced with dscacheutil. When in doubt, type man and then the command you want to use. This will give you the manual page (man) of the command you are trying to use, and most times it's smart enough to give you the updated command instead if it's been changed.


----------

