Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firefox not honoring hosts file

Tags:

firefox

hosts

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.

like image 277
Maarten Avatar asked Nov 13 '19 17:11

Maarten


People also ask

Why does Firefox ignore hosts file?

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.

Does Firefox bypass DNS?

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.

How do I fix a corrupted host file?

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.

Can not change hosts file?

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.

Does Firefox ignore the host 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.

How to look in hosts file in Firefox?

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.

Does Windows 10 ignore the host file?

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

What to do when Firefox fails to search for a name?

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.


2 Answers

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

like image 123
Maarten Avatar answered Oct 15 '22 12:10

Maarten


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)

like image 22
Niente0 Avatar answered Oct 15 '22 14:10

Niente0