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.
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.
- In the window that appears, enter /private/etc/hosts and click the “Go” button. This is a path to this file.
- In the folder opened, click on this file with the right mouse button, select “Open With” and then select “TextEdit”.
- 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”.
- 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.
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.
- Type “127.0.0.1” and press the “Tab” button (->|) so that the cursor move to the right.
- 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)
- 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.
- 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.
- 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.
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.