Why are entries in my hosts file letting websites still install cookies?

I have this in my hosts file.

Why am I still finding cookies from them ?

127.0.0.1 https://lifehacks.stackexchange.com
127.0.0.1 lifehacks.stackexchange.com

I get the "Unable to connect message." when I try to go there.

Which is what I want.

I think you need to use the "top-level" domain, for that to work. Also, you might want to keep the traffic heading for the loopback separate, in case you want to do network stats. So ... enter the following instead, for any related traffic to go into the "void":

0.0.0.0 stackexchange.com

I'm not sure, but I don't think you can block only a sub-domain, like "lifehacks.stackexchange.com" using the hosts file. Maybe someone else knows better.

After saving your hosts file, make sure you run the following command to "clean house":

sudo  resolvectl  flush-caches


If you want something which is Firefox specific, you might consider a plug-in tool such as

2 Likes