1

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?

  • localhost is normally defined in /etc/hosts, but the host command (like dig and nslookup) only queries DNS, not /etc/hosts. Try dscacheutil -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. – Gordon Davisson Sep 3 '18 at 4:31
1

I like using fully qualified DNS and http://xip.io/ explains how to map whatever RFC1918 non-routable address you have set up in docker to avoid the whole localhost mess when you change up your route to the internet.

This ends up being more solid for me rather than munkying about, especially if your tethering is IPv6 only which can complicate things.

  • So what's weird is that this has never been a problem before. – Dave Sag Sep 3 '18 at 3:04
  • @DaveSag Totally weird - and you could get on a new cell tower or get a new profile and then things work again, too. – bmike Sep 3 '18 at 4:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .