Remote WebSocket connection to substrate node on remote server not working

I’m trying to set up a substrate blockchain node on my remote server and connect to it from the web interface. The backend node is running fine on the server, but when I try to access the frontend interface through my server’s IP address instead of localhost, I get connection errors.

The specific error messages I’m seeing are:

  • WebSocket connection to 'ws://server-ip:9944/' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED
  • API-WS: disconnected from ws://server-ip:9944: 1006:: Abnormal Closure

It seems like the substrate node is only accepting local connections on localhost and blocking external WebSocket connections. I need to configure it to accept remote WebSocket connections so the frontend can communicate with the blockchain node.

I’ve already checked that my server firewall is disabled and all ports should be accessible. What configuration changes do I need to make to allow remote WebSocket connections to the substrate node?

That’s a binding address issue. Substrate nodes default to 127.0.0.1 for WebSocket and RPC, so only localhost can connect. You’ll need to bind to 0.0.0.0 instead using --ws-external --rpc-external flags, but heads up - this opens your node to the entire network. For production, I’d use --ws-port and --rpc-port with specific addresses, or throw nginx in front as a reverse proxy for the WebSocket connections. Those unsafe flags other people mentioned work fine for dev work, but don’t ever use them in production since they kill important security protections.

yeah, that’s a classic substrate node issue. add --unsafe-ws-external and --unsafe-rpc-external if you’re in dev mode. also check --rpc-cors - you might need to set it to all so browsers can connect from different origins.

interesting issue! are you using the --ws-external flag when starting your substrate node? that’s prob why it’s only binding to localhost. what’s the exact command you’re running to launch the node? rpc settings can be tricky for remote access.