How to Block Websites on Safari on the Mac Without Parental Controls

Parental controls on the Mac are a good thing. However, you can block websites on Safari on the Mac without parental controls. There are 2 methods that are applicable for this purpose to Safari or any other browser.

How to Block Websites on Safari on the Mac Without Parental Controls

Method 1. Block sites through editing the “hosts” file

The “hosts” file is a kind of database on the basis of which the addresses of the sites are compared in a symbolic form (the names that we enter in the search bar) with their IP addresses.

If you decide to block websites on Safari on the Mac without parental controls in this way, it will come down to registering the forbidden site with the IP address of the local host.

As a result, the browser simply cannot open this address, and the website will be blocked.

Editing the “hosts” file is most convenient through the terminal.

IMPORTANT! Before editing the “hosts” file, we recommend you to back it up in the case if something goes wrong.

To back up this file, follow these steps:

  • Launch Finder
  • Select “Go” in the top menu, and then select “Go to Folder” in the drop-down list.
Select “Go” in the top menu, and then select “Go to Folder” - Mac
  • In the window that appears, enter /private/etc/hosts and click the “Go” button. This is a path to this file.
Enter /private/etc/hosts and click the “Go” button - Mac
  • In the folder opened, click on this file with the right mouse button, select “Open With” and then select “TextEdit”.
Click on this file, select “Open With” and then select “TextEdit” - Mac
  • Select the entire content of the file (“Cmd + C”), create a document in any text editor, paste the contents copied (“Cmd + V”) there and save the file.
  • After that close the “hosts” file.

Editing the “hosts” file through the terminal

To block websites on Safari on the Mac without parental controls through the “hosts” file, start the terminal:

  • “Launchpad” -> “Others” -> “Terminal”
  • In the window appeared, enter the following command to open the file: sudo nano /private/etc/hosts and click “Return”.
Enter the following command to open the file: sudo nano /private/etc/hosts and click "Return” - Mac
  • Then  enter the Administrator’s password and click “Return”.

IMPORTANT. When you enter the password, nothing is displayed in the terminal window. But the system reads your actions. So don’t worry and keep on entering your password.

If you did everything correctly, the file will open for editing and the inscription "File: /private/etc/hosts" will appear in the header.

the file will open for editing - Mac

Now, we should “associate” the blocked site with the local host with the 127.0.0.1 address.

For this purpose, you should perform the following:

  • Move the cursor to the first free line using the arrows on the keyboard.
Move the cursor to the first free line using the arrows on the keyboard - Mac
  • Type “127.0.0.1” and press the “Tab” button (->|) so that the cursor move to the right.
Type “127.0.0.1” and press the “Tab” button - Mac
  •  Then type the address of the site you want to block without http. 
  • After entering it, press “Return” to move the cursor to a new line.
  • If you need to add another site, do the same: type “127.0.0.1”, press “tab” and specify the site name.

TIP. When blocking a site in this document, specify the rules both for simple spelling (namesite.com) and for the version with www (www.namesite.com)

specify the blocking site rules - Mac
  • Now, save the changes. Press “Ctrl + X”, and when the system asks you to save the changes, press the “y” key.

BUT THAT IS NOT ALL. For the changes take effect, you should clear the DNS cache.

  • To do this, type the following command in the terminal: sudo dscacheutil -flushcache;sudo killall -HUP mDNSResponder;say cache flushed and press “Return”. The “cache flushed” voicemail will sound, and the changes will take effect.  

NOTE. This command works on Mac OS version 10.10.4+ and higher. If you have earlier versions of the system, to clear the DNS cache, type:

  • sudo discoveryutil udnsflushcashes – for OS version 10.10 - 10.10.3
  • dscacheutil -flushcache; sudo killall -HUP mDNSResponder - for version 10.9.
  • If none of the commands worked, you can simply restart the computer.

If everything worked out, then when you try to enter the address of the site specified in the file in the Safari address bar, a message will appear that it is impossible to connect to the site.

"Safari Can't Connect to the Server" notice - Mac
  • To  unblock the site, go to the “hosts” file, as discussed above, and simply delete the records you typed earlier to block it.

Method 2. How to block websites on Safari on the Mac without parental controls through the router settings

Blocking sites is possible through the router control panel. To do this, you must know:

  • Address for access to the router control panel.
  • Username and password for the router.

Let’s consider how to block websites on Safari on the Mac without parental controls on the example of Huawei Wi-Fi router.

  • For this purpose, enter the address of the router in the browser (in our case, it is 192.168.100.1; find out your router address from your provider).
  • And then, specify the username and password in the window appeared.
Huawei Wi-Fi router - the login area
  • After entering the router control panel, you should find the section in which blocking the access to sites is carried out.
  • In the case of Huawei, these settings are located in the “Security” section. In other routers, these can be “Advanced” or “Access” sections or something similar.
  • In this section, you need to find the subsection responsible for filtering traffic. In our case, this is “URL Filter Configuration”. It may be called differently in other routers, but the “filter” word is present in the name as a rule.
  • Next, add the sites you want to block to the list and save the changes.
Add the sites you want to block

We’ve considered 2 ways how to block websites on Safari on the Mac without parental controls. And you can choose for yourself which of them is more convenient for you.

And one more thing. When choosing a router option, keep in mind that when you connect Mac to another network, site blocking will not work.

And if you do everything through the terminal, you won’t be able to access forbidden resources regardless of which network the device is connected to.

Expert
William
46 articles7,925 likes
0 responses
Sign in to wright a response.
Read this next
Do you remember from memory all the passwords from the WiFi networks to which your MacBook has ever connected? Likely not. There are at least 3 ways to find WiFi passwords for MacOS.
William
Operating Systems
You had to face a situation where you know for sure that the information on the site of your interest changed (an article or a new photo was added, or something else happened), but the browser does not show this for some reason.
William
Internet Browsers
Maybe, almost every Mac user faced a situation when a computer “falls asleep”. It happens that you put some long task to accomplish (for example, downloading a large amount of information or working with video), go away, and upon returning you find that your Mac fell asleep. So, your task was not completed, and you have to spend your time once more to carry out it.
William
Operating Systems
Written by
William
46 articles7,925 likes
Do you have any question?
Try to use search or ask your question by clicking the button below
Was this article helpful?
No
We’re so sorry :(
Yes
Thanks a lot :D