Skip to content

Instantly share code, notes, and snippets.

@djaiss
Last active August 4, 2024 06:25
Show Gist options
  • Save djaiss/85a0ada83e6bca68e41e to your computer and use it in GitHub Desktop.
Save djaiss/85a0ada83e6bca68e41e to your computer and use it in GitHub Desktop.
Block Twitter/Facebook in your /etc/hosts
# Block Facebook IPv4
127.0.0.1 www.facebook.com
127.0.0.1 facebook.com
127.0.0.1 login.facebook.com
127.0.0.1 www.login.facebook.com
127.0.0.1 fbcdn.net
127.0.0.1 www.fbcdn.net
127.0.0.1 fbcdn.com
127.0.0.1 www.fbcdn.com
127.0.0.1 static.ak.fbcdn.net
127.0.0.1 static.ak.connect.facebook.com
127.0.0.1 connect.facebook.net
127.0.0.1 www.connect.facebook.net
0.0.0.0 meta.com
0.0.0.0 www.meta.com
# Block Twitter
127.0.0.1 www.twitter.com
127.0.0.1 twitter.com
127.0.0.1 apps.facebook.com
# Block Facebook IPv6
fe80::1%lo0 facebook.com
fe80::1%lo0 login.facebook.com
fe80::1%lo0 www.login.facebook.com
fe80::1%lo0 fbcdn.net
fe80::1%lo0 www.fbcdn.net
fe80::1%lo0 fbcdn.com
fe80::1%lo0 www.fbcdn.com
fe80::1%lo0 static.ak.fbcdn.net
fe80::1%lo0 static.ak.connect.facebook.com
fe80::1%lo0 connect.facebook.net
fe80::1%lo0 www.connect.facebook.net
fe80::1%lo0 apps.facebook.com
@Pollik
Copy link

Pollik commented Mar 3, 2020

That is a brilliant attempt at providing a full list. Bravo.

Unfortunately, it didn't work on Twitter. And, just to confirm no rookie mistake, I was running Notepad as administrator

Copy link

ghost commented Mar 16, 2020

That is a brilliant attempt at providing a full list. Bravo.

Unfortunately, it didn't work on Twitter. And, just to confirm no rookie mistake, I was running Notepad as administrator

image

unfortunately for you it actually does work. what kind of sap do you think I am? LMAO. please shoo fly

@ikt
Copy link

ikt commented May 12, 2020

Unfortunately, it didn't work on Twitter. And, just to confirm no rookie mistake, I was running Notepad as administrator

Hey, you'll need to remember to clear your DNS cache otherwise you'll still be able to reach the site as the computer will have the old record stored.

I also noticed Firefox was caching twitter aggressively, you'll want to clear the site cookies and data in Firefox.

Otherwise it's completely blocked now. So thank you to the person above!

@aadilayub
Copy link

@Pollik was experiencing the same problem as you. It was because of caching. Open devtools while on twitter.com, go to the the "application" tab, and then click clear application data. That should do it.

@stayingqold
Copy link

Had the same problem and clearing my cache fixed it.

@cybervigilante
Copy link

No matter what I tried I can't block $$#@%$ Twitter, including using IPV6 blocking. The leeches want you to come back to Mommy Twitter so they've made it Very difficult to block them.

@aadilayub
Copy link

@cybervigilante have you tried opening devtools when you're at twitter.com and clearing the app cache?

@abkrim
Copy link

abkrim commented Jul 1, 2021

That is a brilliant attempt at providing a full list. Bravo.

Unfortunately, it didn't work on Twitter. And, just to confirm no rookie mistake, I was running Notepad as administrator

LoL no rookie mistake, I was running Notepad as administrator I didn't know that using Notepad was getting you off the rookie list

@zefir-git
Copy link

No matter what I tried I can't block $$#@%$ Twitter, including using IPV6 blocking. The leeches want you to come back to Mommy Twitter so they've made it Very difficult to block them.

If all you want to block is twitter.com then it's as simple as 0.0.0.0 twitter.com. These lists are to block any additional subdomains that twitter might be using for e.g. widgets, trackers, analytics, etc. on other websites. So if all you want is to not be able to open twitter.com, that single line is sufficient. The "leeches" can't really do anything to stop you from blocking them; you can literally cut your internet cables and be done with it. you could run your own twitter on your local network for your family to enjoy.

@zefir-git
Copy link

That is a brilliant attempt at providing a full list. Bravo.
Unfortunately, it didn't work on Twitter. And, just to confirm no rookie mistake, I was running Notepad as administrator

LoL no rookie mistake, I was running Notepad as administrator I didn't know that using Notepad was getting you off the rookie list

sudo nano /etc/hosts

@swamp-agr
Copy link

Should it be updated with following lines?

0.0.0.0 meta.com
0.0.0.0 www.meta.com

@cybervigilante
Copy link

Still can't block $#@!$# Twitter with the full list. It's like some kind of evil leech. Thank God Dorsey is leaving. What really stinks is they blocked my account but you can't delete your account if it's blocked so I am stuck with that horror Forever.

@cybervigilante
Copy link

I finally blocked Twitter with a Chrome app, but for some odd reason the blank page I get still has that stupid bird.

@gabrieldocoutos
Copy link

I was also having trouble with Twitter. How I fixed:

  • Go to Twitter
  • Open developer tools, go to the application tab
  • Click on "clear site data"

After that, Twitter was not able to load anymore

@enrico223
Copy link

In addition to that, I also added 0.0.0.0 api.twitter.com

@ambiamber
Copy link

ambiamber commented Jul 1, 2023

If you are using Pi-Hole for blocking just Facebook, you can plug these into the admin web console as wildcard domains:

facebook.com
facebook.net
fbcdn.com
fbcdn.net
fbsbx.com
fbsbx.net
fburl.com
fb.me
fb.com
m.me
messenger.com

Pi-hole wildcard domains match on regex like: (\.|^)facebook\.com$

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment