Block websites on your Mac Block websites on your Mac

The Internet provides access to a lot of useful information, but it can also be very distracting when you want to get something done. Especially nowadays, when almost every website embeds links to Facebook, YouTube, Twitter or other similar services, staying on track is quite difficult. Furthermore, getting kids to stay focused on their homework is even tougher. Fortunately, you can easily block any website that you want. Here's how to do that on a Mac:

In-built solution

If you're not the kind who likes to install third-party application, there's no need to worry; you can block as many websites as you want to without using a specialized tool and it's not that difficult. However, I recommend paying extra attention to what you're doing because if you press the wrong things you may end up blocking sites that you really need, all cutting out Internet access altogether. Just to be sure, lunch the Finder, then choose Go-->Go to Folder , type the following address: /private/etc/hosts and press Enter. Look for a file named Hosts and copy it to a different location so that you always have a backup.

Hosts fileHosts file

Now that that's out of the way, go to the Main Applications folder, select Utilities and open the Terminal. In the Terminal window type this command: sudo nano /etc/hosts and press Enter. You will be asked for your password, so type it in (the cursor won't move while you type) and press Enter. This will open up your hosts file and display a few things in the window. Now, you can actually start blocking off websites: go below the last written line and type 127.0.0.1, pres space then write the website that you want to block (without using http:// in front). For example, if I wanted to block off YouTube, I would type this "127.0.0.1 www.youtube.com". Enter all the addresses that you want to block one under the other, then long press Control + O to save and Control + X to close the window. Finally, type this in the terminal: sudo dscacheutil -flushcache and press Enter; it will clean your cache. Now, all those pesky websites will no longer be accessible on your Mac. To regain access repeat the process and delete the name of the website you want to visit from the hosts file.

Third-party solution

SelfControlSelfControl

If the DIY solution seems like a bit too much trouble, you can always use a specialized tool to help you out and SelfControl is the best solution that I know. Simply download and install the application, then launch it and click the Edit Blacklist button. Now add the websites that are distracting for you, select for how long those sites should be inaccessible and click Start. Just so you know, this tool actually means business and you really won't be able to visit any blocked websites until the timer reaches 0.            

Depending on your needs there are some more advanced solutions such as setting up parental controls or blocking websites at a router level so that no device in your home could reach them, but we will talk about them some other time.

Referenced applications

Cold Turkey
FREE

Windows

rating

Block digital distractions so that you can be more productive.

Cold Turkey
FREE

Android

rating

SelfControl
FREE

Mac

rating

Block your access to various websites and mail servers.

Author's other posts

Mac security tricks
Article
Mac security tricks
If you don't have a lot of experience in using your Mac, here are a few tips that could keep your machine safe from various threats.
Mac Mini 2018: release date, price, expectations
Article
Mac Mini 2018: release date, price, expectations
Apple hasn't updated its Mac Mini line since 2014, so many people are hoping to see a new model this year. In case you're interested, here's what to expect from Mac Mini 2018:
Microsoft Office gets a fresh look and improved searching
News
Microsoft Office gets a fresh look and improved searching
Microsoft is simplifying the command ribbon as well changing up the colors and icons for the applications included in its Office suite.
Best FIFA games for Windows
Article
Best FIFA games for Windows
EA Sports has published a lot of FIFA games over the years, but only a few of them truly shined. Here are the most beloved titles of the franchise: