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
7
  • 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
    Commented Jun 29, 2016 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
    Commented Jun 29, 2016 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
    Commented Jun 29, 2016 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
    Commented Jun 29, 2016 at 14:13
  • How strange. The problem disappeared by itself again. Chrome hasn't updated itself either AFAICT (the version remains the same).
    – aknuds1
    Commented Jun 30, 2016 at 7:56

2 Answers 2

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.

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
1
  • I tried having a single entry for 127.0.0.1, it makes no difference.
    – aknuds1
    Commented Jun 29, 2016 at 23:47

You must log in to answer this question.

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