'WebSocket connection to 'ws://127.0.0.1/ws' failed when run web app
I have a nodejs web app with websocket , when i run on localhost it's not problem but when i run on public host (have SSL,domain name...) i get error : WebSocket connection to 'ws://127.0.0.1/ws' failed .
Solution 1:[1]
Question here is, where are you trying to connect from
Client OR Server
The error message would indicate you are trying to connect to a localhost, so if you are getting this message back from the client side, then its because your connecting to a non-reachable WS instance. Also, if you WS host is https, you would use WSS protocol vs just WS
As mentioned, without seeing the code its hard to tell
Solution 2:[2]
You need to setup your server environment, is your web-server (Apache, nginx) correctly pass requests from world to your node app?.. Is your server firewall pass WS connections?.. IMHO you need a consultation from your provider DevOp's support team.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | proxim0 |
| Solution 2 | ivan |
