How to Block Websites on Safari Mac

Charlotte Daniels

Mac, Tutorials

Are you tired of getting distracted by certain websites while working on your Mac using Safari? Do you want to regain control of your browsing habits and increase your productivity?

Well, you’re in luck! In this tutorial, we will guide you through the process of blocking websites on Safari for Mac, enabling you to stay focused and achieve your goals.

Step 1: Open Terminal

To begin, we need to access the Terminal application on your Mac. You can do this by navigating to your Applications folder, then Utilities, and finally clicking on Terminal. Alternatively, you can use the Spotlight search (Command + Space) and type “Terminal” to find and open it.

Step 2: Access the Hosts File

Once you have opened Terminal, we need to access the hosts file. This file allows us to manually block websites by redirecting their URLs. Type the following command in Terminal:

sudo nano /etc/hosts

You will be prompted to enter your administrator password. Type it in and press Enter.

Step 3: Edit the Hosts File

After entering your password, the hosts file will open in the Nano text editor within Terminal. It may look a bit overwhelming at first, but don’t worry!

We just need to add a few lines of code.

Note: Be very careful when editing this file as any mistakes can disrupt network connectivity. Make sure to follow the instructions precisely.

a) Blocking a Single Website

If you want to block a single website, add the following line at the end of the hosts file:

127.0.1 www.example.com

Replace “www.com” with the URL of the website you want to block. For example, to block Facebook, you would use:

127.facebook.com

b) Blocking Multiple Websites

If you want to block multiple websites, you can add additional lines for each website. Here’s an example:

  • 127.com
  • 127.twitter.com

c) Blocking a Website with Subdomains

If you want to block a website and all its subdomains, use the following format:

127.1 .com

This will block not only “www.com” but also any subdomains like “blog.com” or “shop.com”. Be cautious when using this method as it can have unintended consequences if used incorrectly.

Step 4: Save and Exit the Hosts File

After making the necessary changes, press Control + O to save the file and then press Enter.

To exit Nano, press Control + X.

Step 5: Clear DNS Cache

In order for the changes to take effect, we need to clear the DNS cache on your Mac. Open Terminal again and enter the following command:

dscacheutil -flushcache

Step 6: Test the Block

Open Safari and try accessing the website you just blocked. It should now be blocked and you’ll be redirected to a local page or receive an error message.

Congratulations! You have successfully blocked websites on Safari for Mac. Now you can stay focused and productive without any distractions.

Important: If you ever want to unblock a website, simply open the hosts file again using Terminal and delete the corresponding lines. Remember to save the file and clear the DNS cache for the changes to take effect.

Happy browsing!

Android - iPhone - Mac

 © 2023 UI-Transitions

Privacy Policy