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.
Launch 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.
Now 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.
Next, 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.
Once 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 “127.0.0.1” and press the spacebar. Next, type the specified IP address of the website you wish to block on the same line. For example, type “127.0.0.1 www.youtube.com” to block all traffic from the popular video-sharing site.
Continue to add websites you wish to block in this manner, each beginning with “127.0.0.1.” 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.When 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.
Next, type “sudo dscacheutil -flushcache” and press Enter to flush your existing cache and put the changes into effect. Alternatively, you can restart your computer.
Open 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.