How to block websites on Mac

In terminal.app do:

sudo nano /etc/hosts

Add 127.0.0.1 www.example.com at the end of the file, replacing the domain mane with a domain name you wish to block. For example:

127.0.0.1       facebook.com
127.0.0.1       www.facebook.com
127.0.0.1       twitter.com
127.0.0.1       www.twitter.com
127.0.0.1       instagram.com
127.0.0.1       www.instagram.com

Save with control+o and exit with control+x

Last step it to flush your cache.

sudo dscacheutil -flushcache

I'm an industrial, product and experience designer from Helsinki, Finland. This website is my little corner of the internet. Subscribe if you'd like to receive emails from me when I add something new, and hopefully something worth your time here.