---
"@context": https://schema.org
"@type": TechArticle
"@id": https://www.twilio.com/docs/api/errors/31903#article
headline: "31903: Stream - WebSocket - Connection Broken Pipe"
url: https://www.twilio.com/docs/api/errors/31903
inLanguage: en
dateModified: 2026-04-29T19:18:40.000Z
author:
  "@type": Organization
  name: Twilio Developer Education Team
publisher:
  "@type": Organization
  name: Twilio
---

# 31903: Stream - WebSocket - Connection Broken Pipe

Log Type: APPLICATION

Log Level: ERROR

## Description

Twilio returns this error when a Media Stream WebSocket connection is abruptly closed by the server while the Stream is active. Media Streams use a WebSocket connection to stream call audio to your application, and Twilio must be able to reach your server over a secure WebSocket connection.

### Possible causes

* Your WebSocket server is down or restarted while the Stream is still active.
* Your WebSocket server encountered an application or infrastructure problem that caused it to close the connection unexpectedly.
* The connection between Twilio and your WebSocket server was lost.
* A firewall, proxy, load balancer, or other intermediate network element interrupted traffic between Twilio and your WebSocket server.

### Possible solutions

* Verify that your WebSocket server process is running and stays available for the full duration of the Stream.
* Review your server logs for crashes, restarts, unhandled exceptions, or connection close events that line up with the failed Stream.
* Confirm that your Media Stream endpoint accepts secure WebSocket connections over `wss` and that Twilio can reach it on TCP port 443.
* Review your firewalls, proxies, and load balancers for idle timeouts, resets, or routing issues that can close the TCP socket before the Stream ends.
* If you are using bidirectional Media Streams, make sure your application closes the connection intentionally only when you want to stop the Stream or end the call.

#### Additional resources

* [Media Streams overview](/docs/voice/media-streams)
* [`<Stream>` TwiML reference](/docs/voice/twiml/stream)
* [Media Streams network configuration](/docs/global-infrastructure/firewall-configurations/media-streams-configuration)
