If Firefox appears to be ignoring local
hosts file entries, such as those used for development or to block intrusive (or addictive) services, there are several things to verify on macOS (but the true fix is described last).
Here is an example mapping:
# Hosts 127.0.0.1 dev.me ::1 dev.me
dscacheutil to verify local settings:
$ dscacheutil -q host -a name dev.me name: dev.me ipv6_address: ::1 name: dev.me ip_address: 127.0.0.1
This shows a correct mapping.
sudo dscacheutil -flushcache;sudo killall -HUP mDNSResponder
This flushes the cache and forces a restart of the service.
At this point if the domain resolves correctly in Firefox, then the problem is solved, but the problem more than likely is:
Firefox settings (as of v79.0)
- Access Firefox Preferences from the
Firefoxmenu, or shortcut
- Search for ‘dns’, which should point to Network Settings
- Under ‘Connection Settings’ scroll to the bottom, searching for ‘Enable DNS over HTTPS’
- Uncheck this setting, and try again
This should correct the problem. Firefox is using DNS over HTTPS, so
hosts isn’t followed.
Another solution to avoid disabling DNS over HTTPS completely, is to use a config setting:
about:configin a Firefox tab to access config settings.
- Search for ‘network.trr.excluded-domains’
- A single domain or comma-delimited list of domains may be entered here, but not many
- Add the target domain here, for example ‘localhost’ or ‘dev.me’ in this case
- Close and reopen the browser for this change to take effect
(Also tested and confirmed working on Firefox v79.0, credit to this Reddit response for the last solution.)