Select Language:
If you’re comfortable using Terminal and want to block certain websites on your Mac, this method can be helpful. However, please note that if you’re new to using Terminal commands, it might be better to explore other options like your web browser’s settings. Use this guide carefully and at your own risk.
Blocking specific websites can be useful, especially for parental controls or to help you avoid distractions from sites you don’t want to visit. Here’s how you can do it by editing your Mac’s host file, which tells your computer where to go when you try to visit these sites.
First, you’ll need to open Terminal. To do this:
- Press Command + Spacebar to open Spotlight Search.
- Type terminal and press Enter.
- When the Terminal window opens, you’ll be ready to proceed.
Next, you need to access the host file where you’ll make the changes:
- In Terminal, type:
sudo nano /etc/hosts - Hit Return.
- Enter your admin password when prompted (it won’t show on the screen).
- Press Return again after typing your password.
Now, you’re ready to add the sites you want to block. Here’s what to do:
- Use the Down Arrow key to go below the last line, which usually says
::1 localhost. - Type the following line for each site you want to block:
plaintext
127.0.0.1 fe80::1%lo0 www.facebook.com
127.0.0.1 fe80::1%lo0 facebook.com
Replace facebook.com with any site you want to block, like Twitter or Parler, following the same pattern:
plaintext
127.0.0.1 fe80::1%lo0 www.twitter.com
127.0.0.1 fe80::1%lo0 twitter.com
- Add both the version with www and without, to be thorough.
Once you’ve added all sites:
- Save your changes by pressing Control + O.
- Hit Return.
- Exit the editor by pressing Control + X.
To make sure your changes take effect:
- In Terminal, type:
sudo dscacheutil -flushcache - Press Return.
Finally, close Terminal.
Now, when you try to visit those sites in any browser, you’ll see a blank page because your Mac is blocking the connection. This is a good way to prevent yourself from accessing unwanted sites.
Remember: This technique effectively “loops” these sites, preventing access. It’s a useful tool for parents wanting to restrict site access or for anyone looking to stay focused.
Note: Here’s a quick visual overview of the steps:
- Open Terminal through Spotlight.
- Access the host file.
- Add the blocking entries for each site.
- Save and close.
- Flush the cache.
- Try visiting the sites.
Use this method responsibly, and always back up your data before making system changes.





