My broadband internet died on the weekend and so, in order to get some work done I am tethering my MacBook Pro to my iPhone.
I am running a number of servers within docker containers.
If I deactivate the tethering and just connect to my usual wifi (despite it not having any ability to connect to the outside world due to the broadband being down) then host localhost
works fine. But while tethered I can't resolve localhost
at all. Running host localhost
returns Host localhost not found: 3(NXDOMAIN)
I have tried this on my other Mac too with the same result, which is weird as I regularly travel and work via tethering off my iPhone and it's never been a problem before.
What could cause this to happen and how do I debug / fix it?
host
command (likedig
andnslookup
) only queries DNS, not /etc/hosts. Trydscacheutil -q host -a name localhost
instead; that uses the system resolver, and gives the same results "normal" lookups do. My (wild) guess is that the localhost lookup error is a red herring, and the real problem has to do with IPv6 vs IPv4. /etc/hosts maps localhost to ::1 and fe80:*::1 as well as 127.0.0.1, and if your service isn't listening on all of those, you can get errors when it tries the wrong one first.