Web Developer & Photographer
Menu
menu


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:

  1. Open up Terminal in /Applications/Utilities.
  2. In the command line, type in "sudo nano /etc/hosts".
  3. When asked, type your admin password.
  4. In the screen that will appear, you’ll see the host database for your computer.
  5. Using your down arrow, go to the bottom, right under where it says, "127.0.0.1 localhost".
  6. Type in "127.0.0.1 hit ‘tab’, then enter facebook.com”.
  7. On a new line, type in "127.0.0.1" hit ‘tab’, then enter www.facebook.com"; this is for extra measure.
  8. Now, hold down Control + “O”. This will save the changes to the host database.
  9. Hit “Return” and then Control + “X” to exit the screen.
  10. Remove the existing cache by typing in "sudo dscacheutil -flushcache" in the command line, this refreshes the existing cache on the host database.
  11. You should receive an “Unable to connect” error message when you go to Facebook.com now.
  12. Now, back to doing something more productive…

screenshots: 1 2-3 4-7 10 11

  1. Wow this actually works, thanks!

  2. This is awesome! I’m going to use this during finals this semester. One question however… How do you undo it afterwards?

  3. Simple, just go back into Terminal following the same instructions and locate the website you blocked and remove it.

  4. Ignore the double period in 127.0..0.1. That was just a typo on my part.

  5. Cheers dude!

  6. I’ve tried a few times and it doesn’t seem to be working for me. Do you need to restart your computer or something?

  7. Totally works… thanks muchly

  8. Amazing! Thanks for this!

  9. This worked for me! Thank you!

  10. Heyy 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

Comments are closed.