There are many different web browsers that offer plugins that can help you stay productive, and not open those unnecessary websites. However, you can level it another step higher by simply blocking your computer from accessing specific sites all together.
NOTE: The steps discussed in this article is performed on macOS High Sierra (10.13), although it can also be applicable for Macs that have older version.
STEP 1: Click the magnifying glass at the upper-right corner of the screen.
NOTE: If you’re not seeing the said icon, simply hit the [Command] + [Space] keys.
STEP 2: In the Spotlight Search field, type “Terminal.”
STEP 3: Select Terminal from the search results.
STEP 4: In the Terminal window, type this command: sudo nano /etc/hosts
STEP 5: Hit [Return] to execute the command.
STEP 6: On the prompt, enter your system admin password, then hit [Return] again.
STEP 7: When the host file database displays, tap the down arrow to move your cursor below the line that says “127.0.0.1 localhost.”
STEP 8: Type in “127.0.0.1 [URL]” wherein URL is the address of the website you would like to block.
NOTE: In the example below, we entered “127.0.0.1 facebook.com” to block access to Facebook.com. Make sure to have a space in between the IP address and the URL site.
STEP 9: Hit [Return] to execute the command.
STEP 10: On the next line, enter “127.0.0.1 [complete URL address]” which means re-type the same URL site but with “www.” in front of it this time.
NOTE: This means you need to type in “127.0.0.1 www.facebook.com.”
STEP 11: Hit [Return] to execute the command.
STEP 12: Click [Control] + [O] to save your changes.
STEP 13: Hit [Return].
STEP 14: Next, press the [Control]+ [X] keys, then type this command: “sudo dscacheutil -flushcache”
STEP 15: Hit [Return] once more.
The next time you open that website via any browser on your Mac, you will now be getting this message telling you that you cannot connect to that page.