My Application (React/Websocket) is returning ERR_CONNECTION_REFUSED
I'm trying to make a chat application using React and WebSocket. I created the server-side javascript files and started them with supervisor. However, when I try to connect from the frontend with Websocket, I get the following error in Chrome:
WebSocket connection to 'ws://127.0.0.1:8080/' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED
I already changed the port a few times but it does not help. Maybe someone here could provide some insight.
5 Replies
It may be that your server's firewall has blocked all of the ports that you have tried. To start I may suggest making sure that a) the react application is running and b) the firewall isn't blocking your required ports.
Also, Chrome may not allow unsecured websocket connections to the localhost. Perhaps try Firefox to test. If it works on Firefox but not Chrome, you'll need to swich from a ws
unsecured connection to wss
, which creates a secure connection. This means that you'll also need to proper security certificates on your server.
Any more detail that you can provide might help the community work you towards a solution!
Hi.
Here is some screenshots. And already i try to change ws to wss and this get nothing. In Firefox i also get this error. I spend a lot of time to try to find a solution… Pls, can you help me? What else i can check?
Screenshots:
https://prnt.sc/jafc09
https://prnt.sc/jafcp6
https://prnt.sc/jafde7
https://prnt.sc/jafe44
https://prnt.sc/jafeo8
Are anybody can help me? Pls :(
Here is iptables data
http://prntscr.com/jau5yn
It's difficult to be sure, but from the provided images, it appears that you may have included the loopback address in the client-side javascript code. This would cause the client to attempt to connect to their own computer instead of your Linode.
I would suggest switching the loopback address to your Linode IP address to test my assumption.