Just say no: How to block a website

Blocking methods:

Using Mac OS X hosts file

Blocking websites using Mac OS X works in a similar fashion to blocking them using Windows. The process is free, relatively quick, and requires altering your Mac’s hosts file to redirect a specified domain name. It’s a simple process that will prevent users from seeing content you deem block-worthy across all browsers but that can be reversed should you want to grant access to the sites in the future.

Disclaimer: Altering your computer’s hosts file to block a website can be a little technical. Avoid doing so unless you feel comfortable making the modifications and taking the risk. Proceed with caution.

Number OneLaunch Terminal by accessing the main applications folder, clicking Utilities, and selecting the program from the list. You can also do so by searching for the program in Spotlight.

How to block a website: TerminalFind

Number TwoNow it’s time to make a copy of the host file just in case something goes awry. Type “sudo /bin/cp /etc/hosts /etc/hosts-original” on the Terminal command line to make a backup of the file. Hit Enter and type in your administrative password when prompted. It may appear as though the keystrokes aren’t being registered properly (the cursor won’t move), but they are.

How to block a website: Backup

Number ThreeNext, type “sudo nano /etc/hosts” and hit Enter on the Terminal command line to open up your hosts file in a nano box. Enter your administrative password when prompted.

Number FourOnce the hosts file is opened, you will see several lines of text used for mapping purposes. Underneath the last line of text (it should say something regarding a local host), enter “” and press the spacebar. Next, type the specified IP address of the website you wish to block on the same line. For example, type “ www.youtube.com” to block all traffic from the popular video-sharing site.

How to block a website: Modify-Hosts

Number FiveContinue to add websites you wish to block in this manner, each beginning with “” followed by a space and the appropriate website. Make sure to only use “www” and avoid adding “http”, unless you want to render the entry invalid, and do not alter any other text in the hosts file.

Number SixWhen finished, hold down the Control key and press “O” to save the file changes. Then hold down the Control key and press “X” to exit the hosts file.

Number SevenNext, type “sudo dscacheutil -flushcache” and press Enter to flush your existing cache and put the changes into effect. Alternatively, you can restart your computer.

Number EightOpen your favorite browser and test the results! You should automatically get a blank page whenever you attempt to access any of the sites on your blocked list.

Next Page: How to block a website using your wireless router

Get our Top Stories delivered to your inbox: