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.
That means instead of checking your local hosts file or even your DNS resolver, Firefox simply makes the DNS request over HTTPS from within the browser. This behavior guarantees that the website displayed is pointing to the IP address that the Internet sees as authoritative for that domain.
If you experience issues such as slow loading times or inaccessible websites in Firefox, you can bypass its Domain Name Server settings and use your default Windows ones instead. Firefox is an Internet browser which integrates a DNS cache feature.
To reset the Hosts file back to the default yourself, follow these steps: Click Start, click Run, type Notepad, and then click OK. On the File menu, select Save as, type "hosts" in the File name box, and then save the file to the desktop. Select Start > Run, type %WinDir%\System32\Drivers\Etc, and then select OK.
Contact the administrator to obtain permission” error. Hit the start menu or press the Windows key and start typing Notepad. Right-click Notepad and choose Run as administrator. Now you'll be able to edit and save changes to your HOSTS file.
I do know that older versions of Firefox did not ignore the host file, but mine seems to ignore the host file even after setting the flag for network.dns.offline-localhost I ended up here after a search because I did not understand why I saw this behavior and even after changing the above suggestion, my firefox 71.0 is still ignoring the host file.
Therefore, Firefox already contains the code to look in the hosts file, but it does things in the wrong order: 1. Look up the URL in the DNS server if not found: 2. Send the URL to the default search engine as a search term if not found: 3. Look in the hosts file This is why setting keyword.enabled false fixes the problem.
Windows does not ignore the host file and can be verified easily by a test. I do know that older versions of Firefox did not ignore the host file, but mine seems to ignore the host file even after setting the flag for network.dns.offline-localhost
RESOLUTION: Repair Firefox code so that it attempts to resolve the name BOTH on the web and in the hosts file before using the URL as a search term in the default search engine. After all this time, there is no excuse for not fixing it now.
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
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With