Fortunately, there have already been temporary solutions (SelfControl) that can temporarily block websites on your Mac. If you’re looking for a more ‘permanent’ solution, enter these commands in Terminal:
- Open up Terminal in /Applications/Utilities.
- In the command line, type in
"sudo nano /etc/hosts"
. - When asked, type your admin password.
- In the screen that will appear, you’ll see the host database for your computer.
- Using your down arrow, go to the bottom, right under where it says,
"127.0.0.1 localhost"
. - Type in
"127.0.0.1
hit ‘tab’, then enter facebook.com”. - On a new line, type in
"127.0.0.1"
hit ‘tab’, then enterwww.facebook.com"
; this is for extra measure. - Now, hold down Control + “O”. This will save the changes to the host database.
- Hit “Return” and then Control + “X” to exit the screen.
- Remove the existing cache by typing in
"sudo dscacheutil -flushcache"
in the command line, this refreshes the existing cache on the host database. - You should receive an “Unable to connect” error message when you go to Facebook.com now.
- Now, back to doing something more productive…
sarah
Oct. 18, 2012Wow this actually works, thanks!
Michael
Nov. 24, 2012This is awesome! I’m going to use this during finals this semester. One question however… How do you undo it afterwards?
Mason Sklut
Dec. 2, 2012Simple, just go back into Terminal following the same instructions and locate the website you blocked and remove it.
Bob Smith
Feb. 20, 2013Ignore the double period in 127.0..0.1. That was just a typo on my part.
gus
Apr. 1, 2013Cheers dude!
chloe
Jul. 3, 2013I’ve tried a few times and it doesn’t seem to be working for me. Do you need to restart your computer or something?
Natalie Martin
Jul. 30, 2014Totally works… thanks muchly
Sam
Oct. 19, 2014Amazing! Thanks for this!
TImothy
Jan. 23, 2015This worked for me! Thank you!
Anonymous
Feb. 26, 2015Heyy so I used this once a few months ago and it’s been working but I wanted to alter it. So I went back, deleted the websites I had out in there originally and saved then exited. I reopened it , and after entering the Sudo nano /etc/hosts it doesn’t ask me for a password.it worked before but now it won’t. It goes directly to the screen that’s supposed to come up next .Help ASAP