0

Im getting this message when i try websockets connection with nodejs:

[
  'WebSocket error: heStzDmfg5HKgWKGUHwrGss2EXhnB29vXeNsIay55NNAG7FUx7RuelXQXaKW (ECONNREFUSED) connect ECONNREFUSED 52.198.55.31:9443'
]
[
  Error: connect ECONNREFUSED 52.198.55.31:9443
      at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1146:16) {
    errno: -111,
    code: 'ECONNREFUSED',
    syscall: 'connect',
    address: '52.198.55.31',
    port: 9443
  }
]
[
  'WebSocket closed: heStzDmfg5HKgWKGUHwrGss2EXhnB29vXeNsIay55NNAG7FUx7RuelXQXaKW (1006)'
]

BTW on my local machine it does work just fine. It doesnt work when i run the code on the server because of this error.

How do i make it work?

O. Jones
  • 103,626
  • 17
  • 118
  • 172
  • Blocked from firewall?! "ECONNREFUSED" means it could not reach/create a socket. This can happens because, your firewall is block stuff, or no server is listening on that ip/port. A connection attempt from the browser says https cert is invalid. Perhaps this permit node from etablish a tls socket. Your SSL/TLS settings must be valid. Use the hostname instead of the ip. – Marc Apr 25 '21 at 13:14
  • Let me check the firewalls on the server. – Franklin Noriega Apr 26 '21 at 16:34

1 Answers1

0

ECONNREFUSED means no server is running on the port you try to access (9443) on the machine mentioned in your connection attempt.

So doublecheck the ip address and port, then make sure the server is running. Websocket servers are also https servers (the 443 in 9443 hints at https rather than http ) so try connecting with a browser.

O. Jones
  • 103,626
  • 17
  • 118
  • 172
  • On my local computer it does work the websockets connection with the current settings and also the api endpoints do work from my server and local computer. The only thing not working is the websockets connection from the server – Franklin Noriega Apr 26 '21 at 16:36