I can reproduce this on macOS 11.7.2. I can get is_ok to be false by running nc -l 127.0.0.1 8080 instead of just nc -l 8080. Apparently, netcat is listening by default on some interface other than loopback.
Interesting, the same thing happens for me. The actual context is I am using zmq to communicate with a local server. The zmq server is binding on tcp://*:8080 with a REP socket, and the client is connecting to 127.0.0.1:8080 with a REQ socket.
It seems like it could be a related error with the server listening on all interfaces. Any thoughts?
There's no such thing as an "open port" in isolation; port numbers only mean anything when combined with an address. If your machine has, say, 5 different IP addresses, then there can be up to 6 different sockets all bound to the same port - one for each IP address, and one more for the wildcard address (0.0.0.0, also shown as * in some contexts).
The wildcard address binding will be used if there is no more specific address binding that applies - if you have a socket listening on 127.0.0.1:8080 and another listening on 0.0.0.0:8080 then an incoming connection to 192.168.0.1:8080 will be handled by the wildcard socket, but an incoming connection to 127.0.0.1:8080 will not.