How to block websites on Safari: Mac user guide

Privacy has been a big focus for Apple in recent updates to macOS, and in no application is that more apparent than in Safari. Features, such as the privacy report, which can be displayed on your start page and describe what data websites you’ve visited have collected, and the automatic blocking of third-party cookies, are just a couple of ways it has become a much more privacy-friendly browser. However, privacy isn’t the only reason you may want to block things in Safari. You might want to block specific websites because you don’t want family members or employees to access them on a Mac you manage. In this article, we’ll show you how to block websites in Safari.

Why block websites in Safari?

There are a number of reasons why you may want to block a website in Safari. The most obvious is that you have a child who uses your Mac, and you don’t want them to access websites you consider unsuitable for them. You may also want to prevent yourself from being distracted by certain sites, such as social media websites, while you work. And if you own and manage Macs used by employees, you might want to block websites on them to prevent employees from accessing them while they are working.

How to block websites in Safari

There are a number of different ways to block websites in Safari, including using Screen Time, Terminal, and your router’s admin pages.

Screen Time

The easiest way to block websites in Safari is to use Screen Time. Screen Time allows you to set several restrictions on how your Mac is used, including daily limits on how much time can be spent using apps and scheduling downtime, during which only certain apps can be used. It also allows you to set restrictions for content, such as limiting adult websites and blocking specific sites. Here’s how to use it:

  1. Click the Apple menu and choose System Settings.
  2. Select Screen Time and then Content & Privacy.
  3. Toggle Content & Privacy to on and click Content Restrictions.
  4. Click the drop-down menu next to Access to Web Content and choose Limit Adult Content.
  5. Next, click Customize.
  6. Under Restricted, click ‘+’
  7. Type or paste the URL of the website you want to block.
  8. Click Done.
  9. To block more sites, click ‘+’ again and repeat steps 7 and 8.
  10. Keep repeating those steps until you have added all the sites you want to block.

You can also use the App Limits section of System Settings > Screen Time to limit access to websites. However, the minimum amount of time you can restrict access to a specified site is an hour a day. So, you can’t use it to block sites altogether.

Tip: Manage privacy on your Mac

If your reason for blocking websites on your Mac is that you’re concerned about privacy, there are lots of other things you can and should do, such as clearing your Recent Items list, reviewing and revoking app permissions, and clearing browser data like cache, cookies, search history, and autofill data. The easiest way to do all of that is to use the Privacy module in CleanMyMac X, which can do all of that as well as delete the list of Wi-Fi networks your Mac saves. You can download CleanMyMac X for free here.

Terminal

To block websites in Safari using Terminal, you need to edit your Mac’s hosts file. The hosts file maps the web address you type or click on to the IP address of the web page you’re trying to reach. By mapping a specific URL to your Mac’s own IP address, you prevent Safari from accessing that website. Here’s how to edit the hosts file to do that:

  1. Go to Applications > Utilities and open Terminal.
  2. Type or paste sudo nano /etc/ hosts and press Return.
  3. Type in your admin password.
  4. Look for the line that starts 255.255.255.255
  5. Use the down arrow key to move the cursor to that line and press Return to create an empty line above it.
  6. Type: 127.0.01 followed by the tab key and the URL of the site you want to block.
  7. Press Return.
  8. Repeat steps 6 and 7 for every site you want to block.
  9. When you’re finished, press and hold Control and O to save the file and then Control and X to close it.
  10. Finally, clear your Mac’s DNS cache by typing this command in Terminal followed by Return:
    sudo killall -HUP mDNSResponder
  11. Quit Terminal.

If you ever want to unblock those websites, follow the steps above to open the hosts file and remove the lines relating to the sites you want to unblock. Then, save the file and close it.

Your broadband router

The broadband router supplied by your ISP to allow you to connect to its network has an admin page with lots of settings. Among those settings, there is often an option to block specific websites. You can usually find the IP address of the router admin page and the login details on stickers either on the router or in the manual.

The process for blocking websites using your broadband router varies from router to router, but the general steps are these:

  1. Open a new browser window, type the IP address of your router in the address bar, and press Return.
  2. Log in with your admin username and password.
  3. Go to the Settings page.
  4. Look for an option that allows you to filter content or block websites.
  5. If you don’t see such an option, go to the Advanced settings page and look for it there.
Tip: Browser extensions

Third-party browser extensions are another way to block websites in Safari. The problem with extensions is that it’s very easy to install lots of them and forget you have them. CleanMyMac X’s Extensions module makes it easy to see what extensions you have installed and remove them if you need to.

OpenDNS

OpenDNS is a third-party DNS service that allows you to create a free account and then use its DNS servers instead of those used by your ISP. One of the benefits of doing that is that OpenDNS allows you to block websites on your user account Dashboard.

  1. Go to opendns.com and create a free account.
  2. Log in to your account and go to the dashboard.
  3. Click Settings.
  4. Do one of the following: Click the menu next to ‘Settings for’ and choose a device or network OR Click the IP address of the network on which you want to block the sites.
  5. Scroll down to the bottom of the page and click ADD DOMAIN.
  6. Type in the URL of the site you want to block (it’s best to exclude the www so you include any sub-domains).

Once you’ve added all the sites you want to block, it’s a good idea to clear the DNS cache on your Mac using step 10 in the instructions for Terminal outlined above.

There are several ways to block websites in Safari. Choose the one above that works best for you and follow the instructions to block the sites.

Laptop with CleanMyMac
CleanMyMac X

Your Mac. As good as new.