3 ms·
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
by WhyNotHugo 2y ago
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.
- oulipo 2y agoJust did that on my mac and it seems to work? $ ping hello.localhost PING hello.localhost (127.0.0.1): 56 data bytes 64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.057 ms 64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.162 ms
- Shywim 2y agoNot for me, MacOS 15.4: $ ping hello.localhost ping: cannot resolve hello.localhost: Unknown host
- tedunangst 2y agoThat's because your DNS server sends back 127.0.0.1. The query isn't resolved locally.
- parasti 2y agoI am doing this on macOS with no problem.
- jwilk 2y ago> Any subdomain of .localhost works out-of-the-box on Linux No, not here.
- jchw 2y agoThis 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.
- WhyNotHugo 2y agoYou 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.
- telotortium 2y agoIt's easy to be tricked into thinking macOS supports it, because both Chrome and Curl support it. However, ping does not, nor do more basic tools like Python's request library (and I presume urllib as well).