Skip to contentSkip to navigationSkip to topbar
Page toolsOn this pageProducts used
Looking for more inspiration?Visit the

31902: Stream - WebSocket - Connection Refused


ERROR: 31902

error-31902 page anchor
VOICE
ERROR

Twilio returns this error when a Media Stream cannot establish a WebSocket connection because the destination host refuses the connection request. Media Streams use the <Stream> noun and connect to your endpoint over wss.

Possible causes

possible-causes page anchor
  • The url in <Start><Stream> or <Connect><Stream>, or the Url used with the Stream resource, points to the wrong host, path, or port.
  • Your WebSocket server is down, not listening, or otherwise unavailable when Twilio tries to connect.
  • Your network or firewall is blocking secure WebSocket traffic to your server. Media Streams require secure WebSocket connections on TCP port 443 from Twilio to your WebSocket server.
  • The endpoint is not accepting a secure wss connection. Twilio supports wss for Media Streams.
  • Verify that the Media Stream destination is the correct wss endpoint and that the host, path, and port are correct in your <Stream> url or Stream resource Url.
  • Confirm that your WebSocket server process is running and able to accept incoming connections when the call starts the stream.
  • Update your firewall or network rules to allow secure WebSocket connections on TCP port 443 from Twilio to your WebSocket server.
  • If the refusal was caused by a temporary service interruption, retry the connection after your WebSocket service is healthy again.

Additional resources

additional-resources page anchor