搜尋 Mozilla 技術支援網站

防止技術支援詐騙。我們絕對不會要求您撥打電話或發送簡訊,或是提供個人資訊。請用「回報濫用」功能回報可疑的行為。

Learn More

localhost dns

  • 6 回覆
  • 1 有這個問題
  • 9 次檢視
  • 最近回覆由 jscher2000

more options

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.

Any improvement?

從原來的回覆中察看解決方案 👍 0

所有回覆 (6)

more options

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)

有幫助嗎?

more options

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.

有幫助嗎?

more options

選擇的解決方法

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.

Any improvement?

有幫助嗎?

more options

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.

有幫助嗎?

more options

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.

有幫助嗎?

more options

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:

https://bugzilla.mozilla.org/

有幫助嗎?

問個問題

如果您還沒有帳號,您必須先 登入您的帳號 來回覆文章。請 開始一個新問題