Blocking Facebook with your hosts file

In light of news regarding privacy and Facebook, I looked into a way to keep my web browsing from connecting with FB servers – my effort to be less trackable.  This is a heavy handed domain blocking approach and will break your Facebook.  Read here for information about manipulating your hosts file.  If you are not a Facebook user then you gain a kernel of privacy.

Edit:  This can be achieved with a uBlock for Firefox and Chrome.  I was not able to block Facebook domains using uBlock for Safari.

This will work on any OS with a HOSTS file

1.  Go here –

This wonderful human posted many (I didn’t check if it is all) domains associated with Facebook.  Thank you poster!

2.  Save the contents of file in a text file.

3.  Change all of the to  Use Sed …

Open the file in terminal and run

sed ‘s/’ file from step 1.txt > file you create for step 3.txt

Edit: Don’t use spaces.  It is workable to use spaces it just complicates things slightly.

4. Copy the contents of ‘file you create for step 3.txt’ and paste them into /private/etc/hosts

Done.  Now attempts by Facebook for tracking you through social media plugins/comment systems on your favourite websites will be routed to the localhost, your computer.

I tried this hosts intervention with the + the domains (i.e. and  Both Safari and Firefox ignored the change.  Only when changing to would it work.
As of writing this worked for Mac OS 10.3.4.