ERROR CODES / ENGLISH
OpenAI stream disconnected: handling a cut connection
Why long streaming responses get cut, how to tell a gateway timeout from an upstream interruption, and what to change in the client.
Reviewed 2026-11-13 · ERROR CODES / ENGLISH · Chinese detail: 完整中文页
What it means
The connection was cut during a long answer. In most cases this is a timeout in the middle layer, or a client that does not reconnect.
Error: stream disconnected before completion
ECONNRESET during streaming
The response began but did not finish. This differs from a failure to connect: the first bytes may have arrived, then the stream ended without a completion signal.
Common causes
| Share | Cause |
|---|---|
| 50% | Gateway idle timeout |
| 30% | Client does not handle reconnection |
| 20% | The upstream really was interrupted |
How to confirm
Switch to non-streaming and send the same prompt. If the non-streaming request completes, the streaming path is the problem. If long answers always fail and short ones succeed, the timeout is the likely cause. If the cut is random, the network is the likely cause.
Fix
On your side:
- Raise the gateway read timeout to 300s.
- Implement resume or retry in the client.
- Switch to non-streaming to verify.
On the service side:
- The relay needs to check its buffering and timeout configuration.
If it still fails
| Symptom | Responsible party |
|---|---|
| Non-streaming works | The streaming path |
| Long answers always disconnect | Timeout |
| Random disconnects | Network |
Do not use streaming as the only path for critical business. Add a non-streaming fallback so a cut connection does not fail the whole request.
General guidance, not a statement about any specific provider. For measured data, see the relay directory and method.