Firefox does not use /etc/hosts file

I have the following entries in my /etc/hosts file, to block Facebook and meta services. I know that it is not complete and I will be adding additional hostnames over here.

$ cat /etc/hosts
# Standard host addresses
127.0.0.1  localhost
::1        localhost ip6-localhost ip6-loopback
ff02::1    ip6-allnodes
ff02::2    ip6-allrouters
# This host address
127.0.1.1  myCompute
0.0.0.0    facebook.net
0.0.0.0    facebook.com
0.0.0.0    fbcdn.net
$

If I open a new Firefox instance and then try to open facebook homepage using facebook.com it opens up. On certain sites that use Meta marketing and tracking services there also the connection happens. I can close/kill all Firefox instances and start a fresh one and still the same behavior is observed.

This leads to a conclusion that Firefox does not utilize the entries in the /etc/hosts file.

How can we make Firefox use /etc/hosts file ?

I’m afraid I’m a typical forum guy here. I don’t know the answer to your question, and yet I’m responding.

There is another way to accomplish what you want to do. If you use ublock origin, there is a “My filters” tab under configuration that you can edit and add as many blocks as you like.

Hope this helps.

Go to settings and disable DNS-over-HTTPS

Have you tried restarting your own network interface after saving the /etc/hosts file?

The host file is loaded with the OS. Edit’s to the file generally will not take effect until the next reboot. I use hblock on my system and use Zen and Brave/Helium and it works flawlessly for me.

In my experience, reboots aren’t needed, but you do need to restart your network interface. Disabling it and re-enabling it works.

true but old habits die hard. Windows when I last used it one used to have to reboot in order to get the new hosts loaded even disconnecting the network didn’t remove the hosts from memory back then.

:index_pointing_up:

Fair enough.

Recently I saw a file where they blocked ipv4 and ipv6 for each address, like that:

~~~~

0.0.0.0 block.address.tld

::1 block.address.tld

~~~~

Oh yeah, it might be a good idea to block both IPv4 and IPv6. I guess some ISPs do hand out IPv6 IPs to consumers and some services do use IPv6 too.

I restarted the Network stack/service by giving the command sudo systemctl restart NetworkManager.service. Then checked in mozilla firefox. It was connecting to facebook.com website. The home page of facebook was opening up. Though in a terminal the command ping facebook.com failed.

I restarted the computer and then checked in firefox. It was still connecting to facebook.com website.

I will check next by disabling DNS-over-HTTPS.

If you have dns over https enabled, firefox uses it’s own dns servers.

Thanks for the response. :smiley:

I want the name resolution to fail prior to blocking by ublock origin.

:index_pointing_up:

So disabled DNS-Over-HTTPS and tried to connect to facebook.com and firefox still connected. Please see the screenshot given below for more details on DNS-over-HTTPS being disabled.

Then restarted the browser and tried to connect to facebook.com and it still worked.

Is it connecting to the same url?

btw:

From my experience it is normally just as easy to log out and back in. In saying this I generally reboot after an update just in case, it’s 30 seconds to a minute and a half out my waking hours, I can spare it

For facebook delete your account and you won’t be able to view it and if you don’t want it just don’t use it. I have had addiction issues but the way people act over this is worse than me hanging out for a week