websocat: I/O failure when trying to talk to `localhost`
When I try to connect to localhost, I get this error, but when I use 127.0.0.1 instead, everything is fine. I guess websocat can’t resolve names or something? curl can talk to the server running on localhost just fine.
Would be cool to have this fixed for ease of use. And thank you for the tool, it does seem to work quite well otherwise 👍
E.g.:
user@hostname $ websocat ws://localhost:8080/ws
websocat: WebSocketError: I/O failure
websocat: error running
user@hostname $ websocat ws://127.0.0.1:8080/ws
# no error
user@hostname $ curl localhost:8080/ws
# no error
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 18
- Comments: 24 (11 by maintainers)
Commits related to this issue
- Fix Happy Eyeballs for "tcp:" specifier. Now if one of resolved addresses fails and other connects, we do connect instead of erroring out early. Partially addresses #23. — committed to vi/websocat by vi 2 years ago
- consul: use 127.0.0.1 instead of localhost Otherwise it fails with: ``` websocat: WebSocketError: I/O failure websocat: error running ``` https://github.com/vi/websocat/issues/23 Signed-off-by: Jaku... — committed to status-im/infra-role-nim-waku by jakubgs 2 years ago
- Implement Happy Eyeballs for ws:// Resolves #23. Resolves #194. — committed to sthagen/vi-websocat by vi 3 months ago
Thank you for making websocat. It’s a great tool that has helped me a lot.
If you haven’t already, I suggest you indicate its current “localhost” connection limitation relatively prominently in the documentation. Perhaps in the “limitations” section at the bottom of the current README.md file? It’s trivial to work around if you know about it. It can be a scare-inducing trap for the unwary if you don’t. Asking for a friend.
Websocat 2.0 is going to have Happy Eyeballs and try to connect to both, whichever is faster.
I think I know what happened there.
localhosthas been resolved to two addresses - v6 and v4.websocattried to connect to v6, got rejected and didn’t try v4.By the way, I’m using macOS in case that matters.
I have the same issue on macOS:
Wrong port:
IP Address:
At the same time I can connect without an issue to non-localhost servers:
Though curl works:
It tries connecting to IPv6, make sure it is also being listened on server side.
You can use websocat as a websocket server as well. IPv4:
websocat -s 127.0.0.1:8080, IPv6:websocat -s [::1]:8080. Does it connect to such servers usingws://localhost:8080/?