Blocking Web Sites on a Mac
Sometimes you will find yourself wanting to block certain websites on your Mac computer. This can be for a wide assortment of reasons, but some of them may include:
- Keeping your kids / loved ones / friends out of certain sites
- Blocking sites that you know produce malware / viruses / popups
- Making it more difficult for yourself to access sites to help you stop wasting your time on them
Regardless of your reasoning–these are the steps you’ll want to take to do it.
*Please note that you will need proper permissions to do this*
Step 1: Open the Hosts file
The hosts file is what your computer uses to determine if any websites need to be funneled through specific ip addresses. We use it to funnel unwanted sites back to our machine so that it tries to load a website that doesn’t exist (essentially).
To get to the hosts file, open up a terminal window and type:
This should drop you in to the directory where the hosts file is located. Now you want to open the file with the following command:
That should open the file in the terminal window.
Step 2: Add the offending sites to the Hosts file
The next step is to actually add each site you want to become unavailable to the hosts file. To do this you want to use your arrow keys to move to the end of the file. Now press the “i” key to enter “insert” mode. Enter to make a new line. On that new line you will want to type the following:
Switch out “mysite.com” with whatever the site url of the offending site is. You will want to make a new line for each site, and each iteration of a sites name needs to be included. This means both “www.mysite.com” and “mysite.com” need to be added to effectively block it.
Step 3: Save the Hosts file
Now that the entries are in your hosts file, you will now need to save the changes. To do this, you want to press the “esc” key. This should take you out of edit mode. The last thing you need to do is save the file by typing the following and hitting enter:
This tells the Mac to (w)rite the changes and (q)uit the file.
If the changes were saved successfully you should not be able to view the site in your browser.