6

I've set foo.com to 127.0.0.1 in my /etc/hosts file in (located here on Windows: C:\Windows\System32\drivers\etc\hosts).

Though Chrome loads foo.com with the one hosted locally on port 80, Firefox loads the actual foo.com.

How do I get Firefox to load my locally pointed foo.com?

5
  • Firefox doesn't do that. It uses the OS DNS resolver to convert names to IP addresses. So it depends on how the resolver is configured. Applications such as Firefox have nothing to do with it.
    – Keith
    Jun 16, 2012 at 15:02
  • So how do I configure its resolver to resolve foo.com as 127.0.0.1?
    – A T
    Jun 16, 2012 at 16:10
  • Does Firefox have a proxy manually configured? If so DNS will be offloaded to the proxy server.
    – Zoredache
    Jun 16, 2012 at 17:29
  • @AT That's a Windows admin thing, and I don't do Windows. The fact that that file is in a directory named "drivers" is completely bizarre. I think there is some GUI tool to set these.
    – Keith
    Jun 16, 2012 at 17:53
  • @Zoredache Nope, it has precisely the same proxy settings as Chrome. Keith: Not sure.
    – A T
    Jun 16, 2012 at 18:29

5 Answers 5

3

@guns answer to another question (about DNS lookup) helped me out on this issue. Basically, if a site has an IPv6 address, you need that in your hosts file, too.

127.0.0.1 foo.com
::1 foo.com
2

This can be an issue due to a new feature called "DNS over HTTPS" (DoH).

To disable DNS over HTTPS go to Options -> General -> Network Settings. Then scroll down and deselect the checkmark in 'Enable DNS over HTTPs'

(In other languages, this is called differently, but should be found in Settings, if you search for "DNS")

1
  • A clear way to tell whether one is caused by DoH: the hosts file cannot override existing sites, but it can add non-existing sites. This is because all major browsers (Firefox, Chrome) fall back to DNS if DoH didn’t find the domain. The fallback is intended for corporate environment; most companies have intranet sites hosted under *.corp.example.com. It also means that one can consider a test-only domain to bypass this restriction, if possible. Oct 26, 2022 at 18:24
0

I've ran into this problem before. It seems like Firefox is caching the /etc/hosts file in some fashion. Give it some time.

1
  • how do you force to clear it? I tried 'Clear your history' but that didn't help
    – rubo77
    Feb 12, 2020 at 1:38
0

set both www and non-www version of domain name at /etc/hosts

127.0.0.1 foo.com
127.0.0.1 www.foo.com

It is because firefox checks www.foo.com domain after initial DNS response of no server at foo.com

0

You can also use Trusted Recursive Resolver exceptions with the network.trr.excluded-domains setting in about:config to exclude domains. Set it's value to a comma-separated list of domains like 'localhost,local,foo.com'

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .