Real Time Phoenix Errata P32: wscat doesn't accept localhost

While I can load the website at either localhost:4000 or 127.0.0.1:4000, the wscat command is only working for me when I use 127.0.0.1:4000.

So, to connect, it’s:

wscat​​ ​​-c​​ ​​'ws://127.0.0.1:4000/socket/websocket?vsn=2.0.0'​

I don’t see anyone else having this issue at the wscat repository. I’m on a fresh M1 Mac using the default zsh shell. My /etc/hosts file has the expected link between 127.0.0.1 and localhost.

Just wanted to note this in case anyone reaching this page in the book got frustrated and didn’t think to try switching from localhost to 127.0.0.1. And maybe it’s only an issue on my setup.

2 Likes

Thanks for this report. I’m unsure of the specifics regarding M1 and why it may not work to resolve localhost. It’s good that you found a solution that works for your case. I could see this being addressed as a footnote / callout in case others run into issues.

Same on Tumbleweed (v 22020913), thanks for the tip!