While helping a co-worker I found what appeared to be the most bizarre behavior on their mac. They had set an entry in their hosts file which pointed a domain at a VPN’d internal network address. Normally this would allow the user to bypass the normal DNS lookups and just allow them to work locally. But in this case their computer continued to try to access the internet facing connection. It appeared that MacOS was ignoring the hosts file entries. The hosts entry was something like this: dev.example.com

Hosts file entries are quite useful, and I use them frequently, so I knew it was formatted correctly. But this one wasn’t working, so we started digging. Their local network was on a similar subnet as the VPN (both 192.168.*.* subnets) so we first switched them to a 10.*.*.* network locally. But the change in IP address didn’t seem to address the issue. We changed DNS server settings, and every other tweak I could think of. But then we stumbled on the answer.

Why MacOS was Ignoring the Hosts File Entries

What to change when MacOS starts ignoring your hosts file entriesThis was on MacOS Big Sur (So I am not sure if this holds true for other versions). And their router was supplying both an IPv4 and IPv6 address to the mac. And rightly so, it was preferring IPv6 over IPv4. So our IPv4 only entry in the hosts file was being ignored, because the system would query the DNS over IPv6 first. So in this case we disabled IPv6 by setting it to “Link Local” only. As soon as that change was made the hosts file entries were being honored and my co-worker could get back to work.


This was a very bizarre behavior, and took a bit of sleuthing to discover what was at the root of the issue. But in the end we got to the bottom of why MacOS was ignoring hosts file entries.

If you want to learn how to edit your hosts file try this page for a tutorial.