Shipping an AI app or agent? Security review in 1 working day: $149 / ₹13,900. Request a review →
AI Review Ready
Home / Error fixes / Stream disconnected before completion
Fix · Codex CLI · Codex desktop · IDE

Codex: stream disconnected before completion

What it means: the model's response started and then the connection dropped before it finished. Codex already retried (the Reconnecting... 1/5 lines) and shows this error when the retries run out. The text after the colon tells you which kind of drop it was: look it up in the table below, then retry in a new chat or fix the provider setting it points to.

At a glance
Errorstream disconnected before completion: <reason>
Common reasonsstream closed before response.completed, idle timeout waiting for SSE, idle timeout waiting for websocket, websocket closed by server before response.completed
In Codex's sourceA transient error: Codex retries it with backoff before showing it
Defaults5 stream retries and a 300,000 ms (5 minute) idle timeout per provider; retries are capped at 100
FixRetry in a new chat; check for capacity errors; on a custom provider, raise stream_idle_timeout_ms / stream_max_retries and check the gateway
Reports8 people on GitHub, 26 Nov to 4 Dec 2026, on Windows, macOS and Linux. No OpenAI reply on these issues
Checked5 Dec 2026, against the sources listed below

Read the reason after the colon

Text after the colonWhat it means
stream closed before response.completedThe stream ended without the final "completed" event. Set in codex-api/src/sse/responses.rs (line 639) and the WebSocket client.
idle timeout waiting for SSENo data arrived for the whole idle timeout (default 300,000 ms) on an HTTP stream (sse/responses.rs, line 645).
idle timeout waiting for websocketThe same timeout on the WebSocket connection (endpoint/responses_websocket.rs, line 1118). Reported in Plan mode with GPT-6.2 Astra Ultra, right when Codex finished its analysis and started writing the plan (#65419, #65623).
websocket closed by server before response.completedThe server closed the WebSocket mid-response (responses_websocket.rs, line 1296). Reported together with "Selected model is at capacity" (#65683).
Incomplete response returned, reason: content_filterA content filter stopped the response (protocol/src/error.rs, line 148). Codex adds guidance to the conversation and retries.
tls handshake eof, IO error: An established connection was aborted by the software in your host machine. (os error 10053), Transport error: network error: error decoding response bodyNetwork-level failures quoted by users (#64434, #65213, #65235). The Windows 10053 text itself says software on your own machine aborted the connection.

Fix it

  1. Let the retries finish. Codex's source describes this error as a disconnect "after the HTTP handshake has succeeded but before it finished emitting response.completed", and says "The Session loop treats this as a transient error and will automatically retry the turn." By default it tries 5 times, showing Reconnecting... 1/5 and so on. After that it can switch transports and warn Falling back from WebSockets to HTTPS transport.
  2. Check the lines just above it. If you also see Selected model is at capacity. Please try a different model., the server is overloaded and the disconnect is a side effect: see Selected model is at capacity. Several reporters here saw both (#64434, #65683).
  3. Start a new chat with a smaller prompt. OpenAI's troubleshooting page suggests this for stuck chats. A Windows user reports that fresh sessions in the same workspace generally worked while some sessions left idle for hours kept reconnecting (#65213).
  4. Custom provider or gateway: raise its limits. stream_idle_timeout_ms (default 300000) and stream_max_retries (default 5) are per-provider keys under [model_providers.<id>] in config.toml:
    [model_providers.my-gateway]
    # keep your existing name, base_url, wire_api and env_key lines
    stream_idle_timeout_ms = 600000
    stream_max_retries = 10
    The values are an example. They don't apply to ChatGPT sign-in: Codex rejects config that redefines a built-in provider ("Built-in providers cannot be overridden"). Raising retries isn't a sure fix either: in #65235, a custom provider with stream_max_retries = 10 still failed on error decoding response body with no visible retry.
  5. Find the gateway's real error. In #64124, a gateway user found five different causes (upstream 4xx/5xx, a socket reset, a 300 s gateway timeout, a context-size reject, a safety-screening 503) all shown as the same Codex message. A commenter's tip: send a small streaming request straight to the gateway and read the raw response, since Codex posts to {base_url}/responses:
    curl -N -sS "$BASE_URL/responses" \
      -H "Authorization: Bearer $KEY" -H "content-type: application/json" \
      -d '{"model":"MODEL_ID","input":"Reply with: pong","stream":true}'
    An HTTP error with a JSON body means the upstream error passed through; an event: error or response.failed in the stream carries the gateway's own text; a reset or "transfer closed" points at a dropped socket or a gateway timeout.
  6. Plan mode stalls the same way every time? No fix has been posted. In #65623 retrying reached the same stage and failed again. Send /feedback from that chat so OpenAI gets the session.

Why the message is so vague

Every one of these failures is one error type in Codex (CodexErrorDetails::Stream), so the text after the colon is the only detail you get. Two open issues ask for better reporting: #64124 wants the underlying provider error shown, and #64403 notes that apps built on the Codex app-server receive these disconnects as codexErrorInfo: "other".

Running Claude Code, Codex or Cursor on real repos, or shipping an AI agent? A Quick Review ($149 / ₹13,900, 1 working day) checks one repo, config or setup for leaked keys, risky agent permissions and MCP servers. Request a Quick Review

FAQ

What does 'stream disconnected before completion' mean in Codex?

The response stream dropped after it started and before the final response.completed event. Codex treats it as transient, retries (5 times by default), and shows this error when the retries run out.

What is 'idle timeout waiting for websocket'?

No data arrived on the WebSocket connection for the idle timeout, which is 300,000 ms (5 minutes) by default. Users hit it in long Plan-mode turns.

Can I raise Codex's stream retries or timeout?

Only for a custom provider: stream_max_retries and stream_idle_timeout_ms under [model_providers.<id>] in config.toml. Built-in providers, including ChatGPT sign-in, can't be overridden.

Why does it say Reconnecting 1/5?

That's Codex retrying the dropped stream. 5 is the default stream_max_retries.

Is it the same as 'Selected model is at capacity'?

No, but they often appear together. Capacity is a server overload; the disconnect can follow it.

Related errors

Sources

Read 5 Dec 2026. These tools change often: if a step no longer matches, the linked page wins.

Related free tools