announcement

Share the latest technology trends or photos of gadgets you love.

How to Block Websites on a Mac

How to Block Websites on a Mac

If you are a Mac user and you want to block certain websites, then there are ways to go about it. In this Techspirited article, we show you a few simple ways to restrict access to websites on a Macintosh computer.
Ishani Chatterjee Shukla
Last Updated: Feb 8, 2018
Users /nm./: collective term for those who use computers. Users are divided into three types: novice, intermediate, and expert.
Novice Users: people who are afraid that simply pressing a key might break their computer.
Intermediate Users: people who don't know how to fix their computer after they've just pressed a key that broke it.
Expert Users: people who break other people's computers.

―The Jargon File

If we look around us today, we'll see more people belonging to the third category than in any of the other two. Add Internet to the phenomenon of computer operation expertise and you have a force that can take you places. There are two sides to every coin, and the Internet is no exception. As much as moderation is the key to happiness and success in the real world, it is equally true in the virtual world as well.
Nowadays, it is not an unusual sight to find kids sticking their noses into the computer screen, attacking the keyboard with all their juvenile fury, spending more time on the Internet than with their parents or siblings. This, coupled with a growing trend of Internet addiction in adults and teenagers, leads to a lot of people inquiring about ways to block various websites on different web browsers that pose distractions in the normal course of personal, professional, and social life.
How to Block a Website on a Mac System
There are two ways in which you can block access to websites on a Mac. You can either exercise the Parental Controls option that comes in-built with Mac systems, or you can use the HOSTS file to block sites.
Blocking Through Parental Controls Option
Here's how you can block distracting and detrimental sites in a Mac from the OS itself. This option, however, has a limited scope as you can only place very specific restrictions as provided under the Safari browser.
  • Click on, and open, System Preferences.
  • There, you'll find the Parental Controls option.
  • In case there are more than one user accounts on your system, you will have to specify for which user account you wish to enable the restriction for. You can also create a password protected block.
  • Once you've performed the above mentioned actions, click on Enable Parental Controls.
  • A menu will open, which will ask you to set the control parameters for the web browser and other relevant programs that you use on your Mac.
  • Next, click on the Content tab, and select the restriction options provided for the Safari browser.
  • You can either select which types of websites to block from the options provided by Safari, or you can create a list of websites to which you wish to have access. For the latter, you need to select the Allow Access To Only These Websites option, and create a list of the sites that you want access to.
In this case, you will not be able to get Safari to open any website other than those specifically included by you in the above mentioned list. Once you're done, you can exit Parental Controls and subsequently System Preferences. The restrictions will be saved automatically by the OS.
Blocking Through the HOSTS File
If you want to block access on all browsers, then this is the way to go.
  • You will need to have Mac OS X to do this.
  • Launch the Terminal application. Open the Utilities folder within the Applications folder. There you'll find the Terminal application. Just double-click on its icon to run it.
  • Make a backup of the HOSTS file and type sudo/bin/cp/etc/hosts/etc/hosts-original in the Terminal pane.
  • Hit ENTER when you've done so.
  • You will be asked for the system password, which you must give.
  • Once this has been done, type sudo/Applications/TextEdit.app/Contents/MacOS/TextEdit/etc/hosts in the Terminal.
  • This will cause the HOSTS file to open in TextEdit.
  • Once all the automatic localhost lines have appeared, type in 127.0.0.1 abc.com and 127.0.0.1 www.abc.com, abc being the name of the site that you want to block.
  • You can block multiple sites this way by just adding the names/ URLs of the specific sites in the fashion mentioned above.
  • Exit TextEdit and save the HOSTS file when the system prompts you to do so.
  • Run the dscacheutil -flushcache command in the Terminal to activate the new HOSTS file and flush the DNS
This process can be reversed by following the same steps mentioned above, to access the HOSTS file and delete the lines containing the blocked URLs.
There is another to block websites on a Mac―download and install the SelfControl application. This application is compatible with OS X 10.5 and above, and effectively blocks any website or mail server (both incoming and outgoing) for a specific period of time. This process cannot be undone by any action, not even by restarting your computer. The only way to regain access to the blocked sites is to wait out the timer. In a way, this method is better than the OS level blocks and the password protected blocks, as when you yourself have the key to unlock, it hardly makes sense to put up barricades.