4

According to RFC 2606 (1999) the TLD .localhost is reserved for use for testing locally.

The goal is to configure a preview site to run locally using the TLD .localhost, e.g. http://example.localhost

The problem is that when I use Chrome or Safari to access a '.localhost' TLD it searches google for example.localhost instead of treating it as a proper address. This is after configuring the hosts file to point back to 127.0.0.1.

Am I misunderstanding the usage of this reserved TLD? Is there a way to configure this to work properly?

Community
  • 1
  • 1
dotZak
  • 105
  • 2
  • 8
  • Possible duplicate of [Chrome browser doesn't like a domain with .loc TLD (for localhost domain testing) without http:// - how to fix?](https://stackoverflow.com/questions/7877705/chrome-browser-doesnt-like-a-domain-with-loc-tld-for-localhost-domain-testing) – aude Dec 01 '17 at 16:10

2 Answers2

5

.localhost is not an existing, delegated TLD, which is why your browser doesn't find it.

What RFC 2606 says is that .localhost (along with .test, .invalid and .example) will never be a delegated TLD, so you can safely use that name for your own, local, purposes. That is, if you want to set up a private TLD for internal use, that TLD can be safely named .localhost without the risk of a future collision with a globally assigned name.

Calle Dybedahl
  • 5,228
  • 2
  • 18
  • 22
  • 1
    That's very helpful, thanks. I understand now what the problem is. – dotZak Oct 19 '16 at 02:40
  • The second part of the question is how to get it to work, though. Is it possible to set it up so that it works in all browsers on a local environment, or within a network? – dotZak Oct 19 '16 at 02:40
1

You can add http:// first. Write http://yolo.localhost in your address bar and not yolo.localhost, then it will work.

See answers here for more information: Chrome browser doesn't like a domain with .loc TLD (for localhost domain testing) without http:// - how to fix?

aude
  • 1,372
  • 16
  • 20