How to Block Facebook on Mac OS, Other Web Sites Too

Sometimes we need to block few website on Mac laptop or iMac so that cannot be accessed by users. Especially the social networking sites like facebook and twitter will be in the top list for blocking. Below guide shows how to block facebook on Mac OS including Yosemite, Mavericks and other versions using terminal. This method can be used to block any websites where you want to restrict the access. Since we will be using terminal prompt, it requires basic knowledge of using commands, but do not worry, all are simple and easy to follow.

Basically we will be modifying the DNS database which is located in hosts file like most of the Operating Systems including Microsoft Windows and Linux. We will enter the wrong IP address for facebook or other website which need to be blocked on Mac. So after that the web browser will look for wrong IP to access facebook and finally fail.

Similar altering hosts file method used in blocking facebook on Windows 8 and 8.1 here. Below method is very similar to that but we will be doing it on Mac Operating System.
To modify hosts file in Mac OS, you must be a super user or have that access. Wrong modification of host file will cause issue on DNS related network access in Mac.

Block Facebook on Mac OS by Terminal.

1) Open terminal utility. This can be found under utilities ( Go – Utilities)

Open terminal

2) Type the following command to open hosts file.

sudo nano /etc/hosts

When prompts for password, provide super user password (if you are a super user, then your password).

sudo nano


3) Move the cursor to last entry and enter each entry line by line as shown below.

how to block facebook on mac by hosts entry is a local host’s IP. As per above entries, we point, and to local computer IP address, so the web browser or other applications which need to access facebook will not be able to access correct real IP.

To save the file press Control key  with “O” and press ENTER.

Press Control key with “X” to exit.

If you like, open the file again and check for the new entries.

4) Even though we have pointed out facebook or any other websites to different fake IP, but the local Mac OS will have the DNS cache which was collected earlier. We need to clear the DNS cache (or restart the Mac computer) to take effect of new host entries.

Enter following command to clear DNS cache in Mac OS X.

sudo dscacheutil -flushcache

5) Now open the web browser and try to access I’m sure it will not work and that means we have successfully blocked facebook on Mac.

blocked facebook in Mac

Surly this simple and straightforward method would be helpful on how to block facebook on Mac OS either Mavericks or Mountain Lion or even Yosemite.


We will be happy to hear your thoughts

Leave a reply