Using the '.localhost' TLD searches in browsers instead of showing the site associated with the address

3.8k Views Asked by At

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?

2

There are 2 best solutions below

2
Calle Dybedahl On BEST ANSWER

.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.

0
aude On

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?