-1

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"?

cyclobster
  • 103
  • 1
  • You're using .localhost not .local? will that even work? Just use a proper TLD, I'm not surprised Chrome would have an issue with such an odd thing – Chopper3 Sep 20 '16 at 13:44
  • @Chopper3, Thanks for the comment. Would you be able to tell me why or point me to a reference that explains why ".localhost" is not a proper TLD? As I stated in the question above, RFC2606 seems to say that it is proper unless I'm reading it wrong. – cyclobster Sep 20 '16 at 13:46
  • 1
    As @JamesRyan stated, localhost is not a domain name, it's a hostname. There is not much more evidence you need, this is predefined. And I don't know how Chrome handles this exactly but something.localhost is just wrong syntax. – Broco Sep 20 '16 at 15:01

1 Answers1

5

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.

JamesRyan
  • 8,138
  • 2
  • 24
  • 36
  • Thanks @JamesRyan, buying a proper domain and adding hosts under a subdomain does make the most sense. Do you know if there is any documentation stating that as a best practice or is it just an opinion? Thanks – cyclobster Sep 20 '16 at 15:04
  • 1
    @cyclobster It is quite well discussed in terms of active directory http://serverfault.com/questions/71052/choosing-local-versus-public-domain-name-for-active-directory Although you may not be using active directory a lot of the same reasoning applies. – JamesRyan Sep 20 '16 at 15:10