Localhost:4000/ws WebSocket Connection Error
The ERR_CONNECTION_REFUSED error typically occurs when the server your application is trying to connect to is not running, is down, or is not configured correctly.
I’m encountering an ERR_CONNECTION_REFUSED error when my application tries to establish a WebSocket connection. As shown in the images, it’s trying to connect to localhost:4000/ws but the connection is being refused. I started receiving this error after updating the application’s requirements. Is the server running correctly, or could there be an issue with the configuration? How can I resolve this issue?
My application is working fine, but this warning keeps appearing in the browser console.


2 Replies
I have the same issue. I am running nuxt in a docker environment with a reverse nginx proxy. I was looking for ways to change the url from localhost to development.example.org and change it from ws to wss. I was hoping that with that I could at elast see where it's going wrong
I had some luck playing around with this https://github.com/vi/websocat basically you can connect to it from your browser or your backend, and maybe have an easier time troubleshooting
GitHub
GitHub - vi/websocat: Command-line client for WebSockets, like netc...
Command-line client for WebSockets, like netcat (or curl) for ws:// with advanced socat-like functions - vi/websocat