←back to thread

.localhost Domains

(inclouds.space)
301 points todsacerdoti | 2 comments | | HN request time: 0.411s | source
Show context
WhyNotHugo ◴[] No.43644682[source]
Any subdomain of .localhost works out-of-the-box on Linux, OpenBSD and plenty of other platforms.

Of note, it doesn't work on macOS. I recall having delivered a coding assignment for a job interview long ago, and the reviewer said it didn't work for them, although the code all seemed correct to them.

It turned out on macOS, you need to explicitly add any subdomains of .localhost to /etc/hosts.

I'm still surprised by this; I always thought that localhost was a highly standard thing covered in the RFC long long ago… apparently it isn't, and macOS still doesn't handle this TLD.

replies(4): >>43645195 #>>43645649 #>>43646574 #>>43651614 #
jwilk ◴[] No.43646574[source]
> Any subdomain of .localhost works out-of-the-box on Linux

No, not here.

replies(1): >>43646680 #
1. jchw ◴[] No.43646680[source]
This usually happens because you have a Linux setup that doesn't use systemd-resolved and it also doesn't have myhostname early enough in the list of name resolvers. Not sure how many Linux systems default to this, but if you want this behavior, adjust your NSS configuration, most likely.
replies(1): >>43699895 #
2. WhyNotHugo ◴[] No.43699895[source]
You don't need systemd-resolved for .localhost domains to work. It works on systemd-based distros using another resolver as well as non-systemd distros.

I've never seen this not-work on any distro, must be a niche thing.