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:
- Click the Apple menu and choose System Settings.
- Select Screen Time and then Content & Privacy.
- Toggle Content & Privacy to on and click Content Restrictions.
- Click the drop-down menu next to Access to Web Content and choose Limit Adult Content.
- Next, click Customize.
- Under Restricted, click ‘+’
- Type or paste the URL of the website you want to block.
- Click Done.
- To block more sites, click ‘+’ again and repeat steps 7 and 8.
- 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.
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:
- Go to Applications > Utilities and open Terminal.
- Type or paste
sudo nano /etc/ hosts
and press Return. - Type in your admin password.
- Look for the line that starts
255.255.255.255
- Use the down arrow key to move the cursor to that line and press Return to create an empty line above it.
- Type:
127.0.01
followed by the tab key and the URL of the site you want to block. - Press Return.
- Repeat steps 6 and 7 for every site you want to block.
- When you’re finished, press and hold Control and O to save the file and then Control and X to close it.
- Finally, clear your Mac’s DNS cache by typing this command in Terminal followed by Return:
sudo killall -HUP mDNSResponder
- 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:
- Open a new browser window, type the IP address of your router in the address bar, and press Return.
- Log in with your admin username and password.
- Go to the Settings page.
- Look for an option that allows you to filter content or block websites.
- If you don’t see such an option, go to the Advanced settings page and look for it there.
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.
- Go to opendns.com and create a free account.
- Log in to your account and go to the dashboard.
- Click Settings.
- 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.
- Scroll down to the bottom of the page and click ADD DOMAIN.
- 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.