3 ms·
Ha, I remember back when I first had Jekyll tell me to browse to http://0.0.0.0:NNNN/ http://0.0.0.0:NNNN/ and thinking "This can't possibly be correct, certain
by lotyrin 12y ago
Ha, I remember back when I first had Jekyll tell me to browse to http://0.0.0.0:NNNN/ http://0.0.0.0:NNNN/ and thinking "This can't possibly be correct, certainly that's invalid. Oh, it worked."
Glad I wasn't losing my mind, but this certainly is something people use, I guess it should probably be allowed.
That said, I think a local server that's listening on all interfaces/addresses should probably feel confident to say "please open http://localhost:NNNN" http://localhost:NNNN" I've definitely seen neophytes to various tech get anxious about numbers appearing where they expect a name, and it's less clear what 0.0.0.0 is, if maybe it's something special and different from the "localhost" they're accustomed to (because it is... at least in theory).
- mjevans 12y agoThe difference is that 0.0.0.0 represents all addresses, while localhost is /one of/ those addresses.
- lotyrin 12y agoRight, so it might make sense to go in the listen parameter of an app, but probably not for me to enter into my browser for how I get to that app.
- alex_duf 12y agoYeah 0.0.0.0 is a listening address, not a target.
- ukigumo 12y agonot all addresses but all interfaces, which can have one or more addresses plumbed in.
- hayksaakian 12y agoi was always under the impression that 127.0.0.1 is what you should use
- lotyrin 12y agoThat would account for the case where my local machine doesn't have a host entry for "localhost" but would break if I don't have an IPV4 loopback (if, say, I only have a IPV6 one). Both of those are pretty odd cases, so I'm not sure how much they're worth worrying about.
- eropple 12y agoI could be wrong, because networking is Not My Thing At All, Oh God, Make The Pain Stop, Why Does The Routing Table Have Bees In It, but shouldn't 127.0.0.0/8 be able to find the IPv6 loopback if the IPv4 one does not exist? Or am I misunderstanding yet another part of networking?
- lotyrin 12y agoNope, perfectly possible to not have an IPV4 address. $ sudo ifconfig lo 0 $ ifconfig lo lo Link encap:Local Loopback inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING [... the rest omitted for brevity] $ ping 127.0.0.1 PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data. ^C --- 127.0.0.1 ping statistics --- 32 packets transmitted, 0 received, 100% packet loss
- eropple 12y agoInteresting. I guess I assumed it'd tack a bunch of zeroes on the front and try it as an IPv6 address. Thanks!
- ukigumo 12y agoImagine you are developing inside a VM but use the browser on the host OS to check the results. If the bind address was localhost then you would need to tunnel your connection from host to guest to be able to reach your server. By binding to 0.0.0.0:PORT the guest OS will make your service available on all enabled interfaces:PORT combinations which, hopefully will "just work" in most use cases.
- enneff 12y agoThe right way for a server to do this is to listen on 0.0.0.0 and then examine the socket to see what address(es) it is listening on, and report a real address to the user. It's just laziness (or ignorance) to print 0.0.0.0.
- shurcooL 12y agoYep, exactly this. I do that in a Go app that I posted in my top level comment.