步骤概述
- 验证问题
- 通过反复试验,从最常见的解决方案开始
- 继续直到问题得到解决。
验证问题
问题可能出在浏览器上,也可能出在浏览器之外的设置上。可能有两种浏览器(例如 Chrome 和 FireFox)都有问题,每种浏览器都有自己的原因,或者通过两个浏览器中都不存在的设置。
Chrome 解决方案
Chrome 解决方案 1 - 掺假 hosts 文件,将 .localhost 放在每个主机名的末尾。
在:/etc/hosts:
127.0.0.1 myservername.localhost
Google Chrome Ignoring Hosts File
Chrome 解决方案 2 -(这个问题的答案,这里不再重复)
FireFox 配置解决方案,按可能性降序排列
FireFox 解决方案 1:通过取消选中设置中的功能来禁用 DNS over HTTPS (DoH)。要找到该复选框,请打开 FireFox 设置或首选项,无论您拥有哪个。滚动到第一个面板的底部以查找并单击网络设置。在底部附近有一个标记为“通过 HTTPS 启用 DNS”的复选框。取消选中可能会解决问题。
Why is my hosts file entry being ignored by the browser?
FireFox 解决方案 1a - 如果您想使用 DoH 和您的 hosts 文件,那么您需要使用 DoH 作为您的操作系统的 DNS,因此它位于 hosts 文件之后。
https://www.reddit.com/r/firefox/comments/e64073/dns_over_https_doh_needs_hosts_file/
FireFox 解决方案 2 - 将 network.dns.offline-local 设置为 false。为此,请在地址栏中键入 about:config。单击出现的警告,然后使用配置搜索找到“network.dns.offline-local”。将其切换为假。
https://superuser.com/questions/1433325/does-firefox-ignore-the-hosts-file-how-to-make-firefox-honor-the-hosts-file
FireFox 解决方案 3 - 如果您使用的是 ip6,则使 hosts 文件具有 ip6 条目。
FireFox 解决方案 4 - 在 hosts 文件中设置 www 和非 www 域名。
127.0.0.1 foo.com
127.0.0.1 www.foo.com
FireFox 解决方案 5 - 在 FireFox 中禁用 dns 缓存。为此,请在地址栏中键入 about:config。单击出现的警告,然后使用配置搜索找到“network.dnsCacheEntries”。将其值更改为 0。
FireFox 解决方案 6 - 让自己参与 nsswitch.conf。它涉及如何使用 /etc/hosts。愿原力与你同在。这就是我所拥有的一切。
FireFox 解决方案 7 - 尝试更多配置解决方案:
browser.fixup.dns_first_for_single_words to True
network.dns.disablePrefetch to True
network.dns.offline-localhost to False
network.dnsCacheEntries to 0 (ZERO)
network.dnsCacheExpiration to 0 (ZERO)
network.dnsCacheExpirationGracePeriod to 0 (ZERO)
学分:杰伊·里佐
FireFox 解决方案 8 - 试试这个解决方案:
Navigate to 3 bars > Preferences > General > Scroll to the end > Network Proxy > settings
Configure Proxies to Access the Internet: *CHANGE* Auto-detect proxy settings for this network
I was using Use System Proxy Settings
I also found that is you change tracking in preferences & config this hides the box's too in Firefox
Navigate to 3 bars > Preferences > Privacy & Security > Tracking Protection >Always& "Do Not Track" >Always
AND YOU ALSO have to set this in the browserabout:config`
privacy.trackingprotection.enabled To True
学分:杰伊·里佐
FireFox 解决方案 9 - 如果您正在使用代理,请怪罪您的代理。然后修补它,看看你是否可以修复它。
FireFox 解决方案 10 - 使用 SwitchHost 等插件,希望引入的新问题少于已解决的问题,记住问题可能在一年或更长时间内不会实现。
FireFox 解决方案 11 - 让您自己参与 fireFox 的可信递归解析器 (trr)。它涉及如何使用 /etc/hosts。愿原力与你同在。这就是我所拥有的一切。
FireFox 解决方案 12 - 停止使用 CloudFlare 进行 dns,
https://www.reddit.com/r/firefox/comments/f32enr/firefox_ignores_etchosts_file_on_macbook/
FireFox 解决方案 13 - 如果您的 FireFox 版本是 2008 年的,请升级到更新的版本
http://forums.mozillazine.org/viewtopic.php?p=3274240