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

ShareCause
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:

  1. Raise the gateway read timeout to 300s.
  2. Implement resume or retry in the client.
  3. Switch to non-streaming to verify.

On the service side:

  1. The relay needs to check its buffering and timeout configuration.

If it still fails

SymptomResponsible party
Non-streaming worksThe streaming path
Long answers always disconnectTimeout
Random disconnectsNetwork

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.