![Firefox logo](https://assets-prod.sumo.prod.webservices.mozgcp.net/media/uploads/products/2020-04-14-08-36-13-8dda6f.png)
localhost dns
I am migrating my wordpress based website to a new computer with a LEMP stack on Ubunto 20.04. I wish to access and test the website using the firefox browser offline. I have modified my local dns (/etc/hosts) file to include my site's url but firefox can't find it. Firefox manages to find the nginx greeting and it finds phpmyadmin which is used to manage my database, but it can't locate the wordpress web pages.
One might think I had a problem with my nginx server blocks, but that's not the case because google chrome finds the web pages with no problem.
FIrefox appears to reach out to the internet dns by default and ignore the localhost dns settings. So how do I change Firefox's default settings so that it can access websites on the same computer like Google Chrome does?
被采纳的解决方案
I assume you also tried completely disabling DNS over HTTPS, and that Firefox is not using a proxy? You can check those settings here:
- Linux: "3-bar" menu button (or Edit menu) > Preferences
- Mac: "3-bar" menu button (or Firefox menu) > Preferences
- Windows: "3-bar" menu button (or Tools menu) > Options
- Any system: type or paste about:preferences into the address bar and press Enter/Return to load it
In the search box at the top of the page, type proxy and Firefox should filter to the "Settings" button, which you can click.
The default of "Use system proxy settings" piggybacks on your Windows/IE "LAN" setting. "Auto-detect" can lead to a flaky connection. You may want to try "No proxy".
The DNS-over-HTTPS checkbox is further down in that dialog.
After closing out of that, clear Firefox's web cache and DNS cache.
- Web cache: How to clear the Firefox cache
- DNS cache: type or paste about:networking#dns in the address bar and press Enter/Return
Any improvement?
定位到答案原位置 👍 0所有回复 (6)
Hi, if you are using DNS over HTTPS, then Firefox 83.0 should check the hosts file, but perhaps that isn't fully baked yet. You may need to add the relevant host names to the exceptions list, or turn off DNS over HTTPS.
Some settings you might look at:
(1) In a new tab, type or paste about:config in the address bar and press Enter/Return. Click the button accepting the risk.
(2) In the search box in the page, type or paste TRR and pause while the list is filtered
- network.trr.exclude-etc-hosts => true to read hosts and use it to override the cloud DNS
- network.trr.excluded-domains => list of hosts that require a local DNS lookup (comma-separated list like intranet,jukebox,dev.mysite)
Unfortunately, listing the website url's in network.trr.excluded-domains does not work on my server. I also tried it with network.trr.exclude-etc-hosts set to false with no luck.
My understanding is that setting network.trr.exclude-etc-hosts to true prevents the resolver from using /etc/hosts in resolving the location. Setting it to false should allow it to include /etc/hosts in resolving the location, but apparently it does not.
For developers, this is a serious shortcoming in Firefox for which there appears to be no excuse.
选择的解决方案
I assume you also tried completely disabling DNS over HTTPS, and that Firefox is not using a proxy? You can check those settings here:
- Linux: "3-bar" menu button (or Edit menu) > Preferences
- Mac: "3-bar" menu button (or Firefox menu) > Preferences
- Windows: "3-bar" menu button (or Tools menu) > Options
- Any system: type or paste about:preferences into the address bar and press Enter/Return to load it
In the search box at the top of the page, type proxy and Firefox should filter to the "Settings" button, which you can click.
The default of "Use system proxy settings" piggybacks on your Windows/IE "LAN" setting. "Auto-detect" can lead to a flaky connection. You may want to try "No proxy".
The DNS-over-HTTPS checkbox is further down in that dialog.
After closing out of that, clear Firefox's web cache and DNS cache.
- Web cache: How to clear the Firefox cache
- DNS cache: type or paste about:networking#dns in the address bar and press Enter/Return
Any improvement?
wrknight said
I also tried it with network.trr.exclude-etc-hosts set to false with no luck. My understanding is that setting network.trr.exclude-etc-hosts to true prevents the resolver from using /etc/hosts in resolving the location. Setting it to false should allow it to include /etc/hosts in resolving the location, but apparently it does not.
No, you need to keep it set to true if you want Firefox to read your hosts file and exclude hosts listed in that file from DNS over HTTPS resolution.
I had previously set no proxy with no effect, but disabling DNS over HTTPS did the job.
I guess my final question is why did Mozilla have to make it so difficult?
Many thanks.
The purpose of DNS over HTTPS is to bypass local name resolution; local resolution is used only as a fallback in case the address is not found in public DNS.
Firefox 83 is the first version configured to read the hosts file as an override, and that should be on by default. If that doesn't work with your server's host name, you could file a bug and see whether they can sort out why not: