How To Block Websites On Your Mac

There are three main ways to block websites on your Mac. Youc an use Screen Time, but that only works for Safari. Editing the hosts file will work across browsers and accounts. A better way may be to use a function of your Wi-Fi equipment.
You can also watch this video at YouTube.
Watch more videos about related subjects: Web (79 videos).

Video Transcript

Hi, this is Gary with MacMost.com. Today let's take a look at blocking websites on your Mac.
MacMost is brought to you thanks to a great group of more than 1000 supporters. Go to MacMost.com/patreon. There you can read more about the Patreon Campaign. Join us and get exclusive content and course discounts.
So I'm going to show you two ways to block websites on your Mac. First, you can use System Settings and Screen Time to block a website. But it's kind of awkward to do so. It doesn't work very well. So go into System Settings and from there go to Screen Time. So one place you can go to block websites here is App Limits. If you go to App Limits and you add a limit then you go to the bottom there is Websites. You can expand that here and it will show you websites that you put limits on before or ones that you are currently viewing. You can also Add a website here. Let me add example.com and you could see only the ones that are checked have limits applied. 
Now the limits are certain amounts of time a day that is visible on the screen. You can't use zero. So I can't click Done here because this is set to zero. If I select minutes and I go to 1 then I can click Done. I can also set Custom Limits for everyday. But each day has to be set to at least one minute or you can't use the Done button there. So if you set this to 1 minute and you click Done then you can only go to the checked websites for 1 minute a day. This isn't very effective. First of all it's one minute of visible time. So if you switch between apps it actually seems to last a long time. Second, what you really want to do is block the websites completely. One minute is not good enough. 
Instead, back here in Screen Time we're going to go to Content & Privacy. We're going to turn that On. Then we're going to turn On Content Restrictions and the first item here is  Access to Web Content. Now the options are either Unrestricted Access, Allowed Websites Only, or Limit Adult Websites. There is no option here to simply block a few websites and allow everything else. Well, it doesn't seem like there is. Actually Limit Adult Websites is that option. So it is kind of awkward to choose that because it's not exactly what you want but it will get the job done. Then you have a list of Allowed  and Restricted sites here. This is where you can add a website. So I could add a site like that there and now that is Restricted. Now you can't go to that website at all. 
Now if we go, in here in Safari, and try to go to this website and it doesn't seem to work right away. But after a short amount of time it suddenly will be blocked. But if I switch to another browser, like for instance Chrome, and I go to the site it works perfectly fine. Screen Time, of course, is integrated into Apple's apps like Safari, but a third party app like Chrome made by Goggle doesn't use Screen Time. So it's not going to block this site. The same thing with Firefox. It doesn't pay any attention to Screen Time.
So if you're setting this up to block web access to sites for a child, say, this isn't very useful. You would have to set it up where they don't have any other apps available to them and you block access to The App Store and all of that. There is another method to do it. One that has been around for a long time and doesn't involve Screen Time at all. But it does involve using the Terminal. 
So you want to launch Terminal and then you're going to Edit what is called the Host's File. To do that you're going to need Admin permission. So you want to start with sudo which will give you Admin permissions but it is going to ask for your password. Then you're going to do nano which is a simple text editor that is easy to use. You're going to edit/etc/hosts. It is going to ask for the password and now you're editing this special Host file. The lines that are already there you want to leave completely alone. You don't want to edit these at all. That's very important. So you just want to use the Down Arrow to go down to the bottom. Then maybe Return to insert a blank line. This is where you will put new stuff. 
Any site you want to block just want to type 127.0.0.1. That is just the local address of your Mac. So of course if you try to go to a website it is not on your Mac, it's out on the internet. So setting it to this will mean that it simply won't work. Then you're going to Tab and then put the name of the site. So, I'll type example.com here. Let's do another one. Let's do yahoo.com. Now you're going to do Control X to exit. It's going to ask you if you want to Save and you'll say Y for yes. Then Return because you're going to save it with the same name. Now that is saved. 
Now let's try to example.com. Remember I turned the Screen Time setting Off. So I try to go here and you can see it simply says Can't Connect to the Server. Now you can see here in Safari yahoo.com still works. So here are some trouble shooting tips. First of all notice that the domain here is www.yahoo.com. So back in Terminal let's edit that file again and let's add that as well. You would also need to add others like, for instance, Finance.yahoo.com or Mail.yahoo.com. Let's save that. 
Next we want to make sure in Safari, under Settings, Privacy that we're not using Hide IP Address from trackers that will bypass the Host File using this special Privacy feature and so it won't pay attention to the ones we want to block. If I Refresh you can see it still shows up. So try quitting Safari and going back in. Now you can see it blocks. 
There are also a variety of commands you can use for the Terminal if it just doesn't seem to be working. This one here will clear out the cache of IP addresses that your Mac has that could temporarily give your Mac the ability to still show the website if you've just made the change. But you really shouldn't need to do this anymore. It's worth trying though especially if you are using an older version of macOS. Another command is this one as well. Use that after clearing the cache to kind of reset things for looking up IP addresses. Of course remember that you've got this set here as it should be blocking all web browsers and all users on the Mac. So you want to make sure that you get rid of it if you want to restore access. An easy way to do that without having to retype everything the next time you want to use it is put a # or hash symbol just before each line that comments it out so this is considered a comment, not an actual command. Now when I save this, because I have those there, I can now Return to yahoo.com and example.com and they work fine. 
Another thing you may want to consider that goes beyond just your Mac is actually blocking websites at the router level. So how to do this varies very much depending upon what sort of network equipment you've got. You either have an app maybe on your phone or a special web address that you can go to on any browser and you can change the settings on your WiFi equipment so that it blocks certain websites for the entire household. So look into that if you want something more comprehensive. 
Hope you found this useful. Thanks for watching. 

Comments: 3 Comments

    James Ford
    2 years ago

    I usually update my computer within a week of the release of an update. After the most recent update I started having problems acessing websites I had not previously visited. The error message was similar to the one at the 2:34 mark of your video. I tried numerous fixes and nothing worked. Since the error was coming via Screen Time I simply turned it off and no more problem. Some Screen Time setting had been change by the update, which seems to be happening with recent updates.

    Jim terrinoni
    2 years ago

    Informative and easy to follow. I’d love to see an episode geared towards setting rules in the Mail app.

    2 years ago

    Jim: I would start with this one, using iCloud rules instead of doing them on one machine only: https://macmost.com/why-you-should-use-icloud-email-rules-and-not-mail-rules-on-your-mac.html But if you are using something else for email, like Gmail, then obviously you'd need to use their rules system.

Comments are closed for this post.