Firefox not honoring hosts file
Asked Answered
T

7

12

Firefox does not honor the hosts file when browsing to an URL. For example;

My hosts file says 127.0.0.1 local.webdev.com and entering the local.webdev.com URL into the address bar sends me to the internet always, not localhost. Browsing to this URL in another browser works fine.

Tolbert answered 13/11, 2019 at 17:14 Comment(0)
T
8

There is a new feature in Firefox called "DNS over HTTPS" which you may have (accidentally) enabled. Having this option enabled sends your DNS request directly to your DNS server instead of to your OS, which is the default.

Go to Settings -> General -> Network Settings -> Enable DNS over HTTPS and disable this option.

This makes sure that your DNS request goes to your OS which will read the hosts file first before going to your DNS

Tolbert answered 13/11, 2019 at 17:14 Comment(3)
This worked for me. For what it’s worth I’m almost completely certain I didn’t enable this manually, and that it became the default behavior. I’m in Firefox 81.0.1.Bumbling
You can continue to use "DNS over HTTPS" and use the /etc/hosts by setting "network.trr.excluded-domains" or "network.trr.exclude-etc-hosts" to False.Quadruplex
Er, network.trr.exclude-etc-hosts (added in Firefox 83) must be set to true (the default) for the /etc/hosts file to be used. The only gotcha is that you have to restart or flip the pref (twice) after changing the hosts file.Mercator
Z
3

The solution for me was to enter "about:config" in Firefox address bar, then add a boolean value named:

browser.fixup.dns_first_for_single_words

and then set it to true.

(currently working on Firefox 78.0.2)

Zapata answered 22/7, 2020 at 15:42 Comment(1)
on Firefox 81.0 'DNS over HTTPS' seems to be disabled by default (?) however setting single word to true made my troubles go away (... those troubles regarding the scope of this question at least)Lapides
U
1

The issue in my case was fixed simply by prepending the HTTP protocol to the URL, for example:

http://
+
thetoppers.htb
→
http://thetoppers.htb
Uplift answered 1/7, 2023 at 12:47 Comment(0)
B
1

The problem was of my own doing... due to previous issues, I had enabled network.dns.disableIPv6 and the host I am trying to reach (for which I had set an /etc/hosts entry) was on IPv6-only.

Basically: if your /etc/hosts entry is for IPv6, then make sure you did not disable IPv6 address resolving in about:config!

Borszcz answered 15/10, 2023 at 14:11 Comment(0)
G
0

I had this same problem.

Not sure if it's a complete solution, but I noted the following in my case:

  • When I gave the page a normal refresh (F5, Ctrl+R, Refresh Button) it wouldn't respect the 'hosts' DNS.
  • When I used clear cache / reload (Ctrl+Shift+R, Ctrl+F5, Shift+Refresh Button), it worked fine every time.
Gutsy answered 15/2, 2021 at 15:2 Comment(0)
G
0

In my case the problem was from the proxy I had set in:

Settings -> General -> Network Settings -> Settings

enter image description here

enter image description here

Gyromagnetic answered 8/9, 2022 at 12:18 Comment(0)
W
0

For me the issue was the website was being served over ipv6, but I had only changed the ipv4 address in my hosts file. Once I added an ipv6 line to the hosts file it started working as expected. If you go to about:networking#dns you can see whether or not the website is ipv4 or ipv6 in the "Family" of the table.

Wideman answered 10/11, 2022 at 17:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.