←back to thread

.localhost Domains

(inclouds.space)
301 points todsacerdoti | 2 comments | | HN request time: 0.407s | 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 #
oulipo ◴[] No.43645195[source]
Just 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
replies(2): >>43645300 #>>43647295 #
Shywim ◴[] No.43645300[source]
Not for me, MacOS 15.4:

    $ ping hello.localhost
    ping: cannot resolve hello.localhost: Unknown host
replies(1): >>43646672 #
1. fimdomeio ◴[] No.43646672[source]
I think I had mixed results on mac depending on the network I was connected to. I think it has something to do with ipv4 vs ipv6
replies(1): >>43662879 #
2. g0db1t ◴[] No.43662879[source]
Ironically for me it works on my MacOS laptop but not on my Debian 12 VPS