0

If I define subdomains in /private/etc/hosts on OS X, such as test.localhost, Google Chrome (51.0.2704.106 (64-bit)) isn't able to resolve them (even though it worked until today). Other browsers (e.g. Firefox) are able to resolve them just fine on the other hand.

The reported error is this:

The following error was encountered while trying to retrieve the URL: http://test.localhost:8080/

Unable to determine IP address from host name test.localhost

The DNS server returned:

Name Error: The domain name does not exist. This means that the system was not able to resolve the hostname presented in the URL. Check if the address is correct.

Why is Chrome unable to resolve subdomains from the hosts file?

My /private/etc/hosts file currently looks like this, the last entry being the one I'm testing:

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1   localhost
255.255.255.255 broadcasthost
::1             localhost
fe80::1%lo0 localhost
192.168.59.103 plugins.docker
192.168.59.103 login.docker
127.0.0.1 test.localhost
aknuds1
  • 9,368
  • 6
  • 28
  • 27
  • It's unlikely to be the problem, but you may want to use a different IP address for test.localhost just in case Chrome is having issues with multiple names for the same address on different lines. Try 127.0.0.2. – user Jun 29 '16 at 13:04
  • @MichaelKjörling 127.0.0.2 doesn't work at all, in any browsers. The IP itself hangs (in every browser), but Chrome still isn't able to resolve the subdomain. – aknuds1 Jun 29 '16 at 13:08
  • There shouldn't be any problem with using the same IP for different hostnames. And the "subdomain" thing is a red herring. But I just wonder if there is a conflict with using `localhost`? Have you tried `test.somethingelse`? – MrWhite Jun 29 '16 at 13:53
  • @w3dk It's apparently not a red herring, because the hostname 'test' works (as opposed to test.localhost). Yeah, test.somethingelse doesn't work either. – aknuds1 Jun 29 '16 at 14:13
  • How strange. The problem disappeared by itself again. Chrome hasn't updated itself either AFAICT (the version remains the same). – aknuds1 Jun 30 '16 at 07:56
  • Quite a few hallmarks of a caching issue. (?) – MrWhite Jun 30 '16 at 12:13
  • @w3dk Not sure, it's all very mysterious. Why did this problem start appearing by itself, if it was due to caching I wonder? – aknuds1 Jun 30 '16 at 12:19

2 Answers2

1

The cause of this error was the ZenMate proxy extension being enabled in Chrome, apparently it is unable to handle "subdomain" local DNS entries.

aknuds1
  • 9,368
  • 6
  • 28
  • 27
0

You probably need to have a single entry for 127.0.0.1. You can add multiple names for any address just by listing them with spaces in between them:

127.0.0.1 localhost test.localhost example.com
::1 localhost test.localhost example.com
Spiff
  • 101,729
  • 17
  • 175
  • 229