Conflict with Chrome and RFC2606

RFC2606 states the following for the “localhost” tld:

The “.localhost” TLD has traditionally been statically defined in
host DNS implementations as having an A record pointing to the
loop back IP address and is reserved for such use. Any other use
would conflict with widely deployed code which assumes this use.

So if I’m reading this correctly, the IETF says that “.localhost” is a good tld for local website development. As such, my company requires that all of our local development projects use the tld “.localhost”. (We use Vagrant + Puppet to keep all of our dev environments identical across the team). For example the hosts file will have entries like this:

192.168.10.10 someproject.localhost
10.9.8.7 anotherproject.localhost

Here’s the problem, this tld works fine in all browsers EXCEPT Chrome. Chrome gives a ERR_CONNECTION_REFUSED message whenever the localhost tld is used. If I change the tld like so:

192.168.10.10 someproject.loc
10.9.8.7 anotherproject.loc

Chrome works fine. In fact, I’ve tested a number of different arbitrary tlds and they also all work fine in Chrome. “localhost” is the only tld that gives the ERR_CONNECTION_REFUSED message on Chrome.

I’m using Windows 7, Chrome version 53.0.2785.116 m (64-bit). But I get the same error on Windows 10. Everyone on my team also gets the same error whether they’re on their home or work computers (Windows and Mac).

Why is Chrome unable to connect when the tld is “.localhost”?

Answer

What you are doing is wrong.

localhost is a hostname pointing to 127.0.0.1 not a domain, so adding hosts to it as if it is a domain but pointing somewhere else is logically incorrect.

You may be getting confused with the .local domain however there are reasons not to use that either which are already answered in other questions. Essentially you shouldn’t be making up a fake domain you should get a proper domain and then add hosts under a subdomain of that in your hosts file/local dns.

Attribution
Source : Link , Question Author : cyclobster , Answer Author : JamesRyan

Leave a Comment