My Application (React/Websocket) is returning ERR_CONNECTION_REFUSED

Linode Staff

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://' 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!

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?

Are anybody can help me? Pls :(
Here is iptables data

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.

Thanks for your help!)
I figured out and now i get a connect but in nginx's log i get this error: "upstream sent no valid HTTP/1.0 header while reading response header from upstream"
Are anybody can help me?


Please enter an answer

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct