Does Firefox ignore the hosts file? How to make Firefox honor the hosts file
Solution 1
I had the same problem. Write about:config in the address bar.
Search for dns and change network.dns.offline-local
to false.
Solution 2
I fixed it by disabling the "DNS Over HTTPS" Firefox Network option.
Solution 3
If the domain that is not working either in Firefox or Chrome ends as following:
.dev
.localhost
.test
.example
.app
The problem is that, both browsers in certain distributions don't like domain ending like that, in my case changing the domains from *.localhost
to *.local
solved the issue.
As I mention in a comment in this post where I found the solution, it happens in certain distributions, eg. I don't have this issue in my Ubuntu 20.04 installation, but I got the error in Xubuntu 20.04 (both browsers).
Related videos on Youtube
user9371654
Updated on September 18, 2022Comments
-
user9371654 almost 2 years
I'm using Firefox browser in Ubuntu 18.04. I made an experiment where I want some domain names to be resolved to another IP address than their actual one. Firefox seems to ignore the IP in the hosts file.
1) Is this expected behavior from Firefox?
2) If yes, how to make Firefox honor the hosts file?
3) If not possible, are there alternative browsers that honor the hosts file?
I use Linux Ubuntu 18.04
-
Zeitounator about 5 yearsI use the hosts file to direct well known adds sites to 127.0.0.1 as a cheap add-blocker and it works very well. So the answer is no, firefox (as all other browser I've tried) honors
/etc/hosts
. You should double check your hosts file content. -
DrMoishe Pippik about 5 yearsWindows 10 itself will ignore hosts, e.g. when used to block telemetry. See petri.com/…
-
LMiller7 about 5 yearsI don't know much about Linux but in Windows browsers don't consult the hosts file. That is done at a lower level in the system and the browser has no choice whether it is used or not. I suspect a problem in the hosts file.
-
user1686 about 5 yearsThe browser (on PC operating systems) always has a choice to not use the system-provided mechanisms in the first place. It can send its own UDP packets or make TCP connections.
-
Eddie over 3 yearsipv6 was the problem for me. Solution here: superuser.com/a/753863/77247
-
-
Nick Woodhams almost 5 yearsAfter switching this, I just needed to close Firefox entirely and reopen and it started to honor the hosts file. Thanks.
-
RockPaperLz- Mask it or Casket over 4 yearsOn what operating system did you run your tests?
-
Universal4 over 4 yearsWindows 10 Firefox 71.0 As I stated I have used the hosts file for MANY years for many reasons such as test sites of live domains in a different ip, or servers on my lan etc. the recent few revisions of firefox made some sort of change the last year or so that just seems to drive me into brick walls ina number of places that may force me to change but I would rather conquer the underlying reasons and continue to use my preferred browser
-
Gary - Stand with Ukraine about 4 years+1. By design, DNS Over HTTPS ignores hosts files. See bugzilla.mozilla.org/show_bug.cgi?id=1453207#c2
-
Alex about 4 yearsThis was my answer too! Thank you @Erpallo. I tried everything and you saved the day!
-
michael about 4 years😲 omg, TIL (btw: wtf?!)
-
Lubo Kanev over 3 yearsFirefox still ignores the hosts file after following this and the other answers, even after restart. I noticed if I create a new Firefox profile, it works there.
-
Nickolay over 2 yearsFirefox 83+ honors /etc/hosts with the default settings, but you do need to restart after making changes to the hosts file.