Codex “stream disconnected before completion”: what it means and how to fix it
What Codex's “stream disconnected before completion” error means, how to read the text after the colon, and what to try in each case.


The short answer
Codex streams each reply from the server. “stream disconnected before completion” means the connection was made and the reply had started, but the stream ended before the server sent its final response.completed event. Codex treats this as temporary and retries on its own, showing “Reconnecting… 1/5” (five retries by default; after that it can also fall back from WebSockets to HTTPS). You only see the error once those retries have failed, so the cause is almost always the network between you and the server, or the relay you set as the endpoint, not your code.
- Send it again
Resend the message, or ask Codex to continue. The thread keeps everything up to the failed reply, and changes Codex already made to files are still there.
- Read the text after the colon
It says where the connection broke. The table below covers the common ones.
- Take the proxy, VPN or relay out of the path
Try once without it, or switch to another node. If the error goes away, the cause is in that hop.
- Update Codex
Recent versions wait for the network to come back (“Reconnecting… waiting for network”) instead of failing when the connection can't be made at all.
What the text after the colon means
| The error ends with | What happened | What to try |
|---|---|---|
transport error: network error: error decoding response body, error sending request | The connection dropped while the reply was coming in, or the request never got through. | Check the network, turn the proxy or VPN off or switch nodes, then send again. |
stream closed before response.completed, websocket closed by server before response.completed | The server, or something in between, closed the stream early. | Send again. If it happens on every long reply, a proxy or relay in the path may be cutting long connections. |
idle timeout waiting for SSE | Nothing arrived for five minutes, Codex's default idle timeout. | Send again. With a custom provider you can raise stream_idle_timeout_ms (see below). |
tls handshake eof, peer closed connection without sending tls close_notify | The encrypted connection was cut off, often by a firewall, proxy or company network. | Try another network or node. If your company network inspects TLS, point CODEX_CA_CERTIFICATE at its root certificate (a PEM file). |
our servers are currently overloaded | OpenAI's side is busy. | Wait a little and send again. |
concurrency limit exceeded…, upstream request failed, upstream service temporarily unavailable | Codex doesn't use this wording; it usually comes from the relay or gateway set as your endpoint. | Ask whoever runs that relay, or switch back to signing in with ChatGPT. |
Windows os error 10061 (the target machine actively refused it) | Nothing is listening at the address Codex tried. Often it's a local proxy or relay on 127.0.0.1 that isn't running. | Start that proxy or relay, or remove the setting that points Codex at it. |
Windows os error 10054 (forcibly closed by the remote host) | The other end reset the connection. | Usually the network or the proxy node. Switch nodes and send again. |
Windows os error 10053 (aborted by the software in your host machine) | Something on your own computer cut the connection. | Check the proxy client, firewall and antivirus. |
Incomplete response returned, reason: content_filter | Not a network problem: the reply was stopped by the content filter. | Rephrase the request. |
“Error running remote compact task”
When a thread gets long, Codex asks the server to compact the earlier history. If that request drops, the error starts with “Error running remote compact task: stream disconnected before completion…”. The causes are the same as in the table. Send again; if it keeps failing on a very long thread, start a new thread.
Retry settings, and when they apply
Codex has three per-provider settings: request_max_retries (default 4), stream_max_retries (default 5, up to 100) and stream_idle_timeout_ms (default 300000, five minutes). They go under a custom provider in Codex's config.toml. The built-in openai provider, the one you use when you sign in with ChatGPT, can't be overridden, so these settings don't apply there. To send the built-in provider through a proxy, Codex's docs say to set openai_base_url instead.
model_provider = "myrelay"
[model_providers.myrelay]
name = "My relay"
base_url = "https://relay.example.com/v1"
env_key = "MYRELAY_API_KEY"
wire_api = "responses"
stream_max_retries = 10
stream_idle_timeout_ms = 600000When Codex keeps dropping in Mirasim
Mirasim runs the Codex CLI itself, on your ChatGPT sign-in, an API key or Mirasim credit, so the same error and the same fixes apply. What it adds: the agent is picked per session, and a session can switch to another agent, such as Claude Code or Kimi Code, and keep its conversation. A task doesn't have to wait for Codex's connection to recover.
Chapter 16 · Models, accounts and quota › Model and reasoning level are per session → Picking the agent and model for each session.
Article · The Codex app: where to get it now, and running Codex next to other agents → Installing Codex: the desktop app and the CLI.
Article · How to install and update Codex CLI on macOS, Windows and Linux → Updating Codex CLI, whichever way you installed it.
Questions
- Is my work lost?
- No. The thread keeps everything up to the failed reply, and files Codex already changed stay changed. Send the message again or ask it to continue.
- Why does it say “Reconnecting… 1/5”?
- Codex is retrying on its own; 5 is the default
stream_max_retries. If a retry gets through you won't see the error at all. - Can I raise the retries when I sign in with ChatGPT?
- No. The retry settings only apply to custom providers; the built-in
openaiprovider can't be overridden. - Is something wrong with my code or repository?
- No. The error is about the connection that carries the reply. The one exception is
content_filter, which is about the request itself.
Sources
The behaviour and defaults come from the Codex source at github.com/openai/codex (the error definition, the retry loop, the provider defaults and the streaming client) and Codex's Advanced Configuration and Environment variables docs, checked on November 22, 2026. The Windows messages are the standard Windows Sockets errors WSAECONNREFUSED, WSAECONNRESET and WSAECONNABORTED. Codex changes often; check its docs for the latest.
Keep reading

Claude Code for teams: access, shared setup, and working in one session
How a team uses Claude Code: a seat for everyone, the setup in the repo, sessions shared by link. And what to do when several people must steer one session.

Codex on Linux: the desktop app, the CLI, and servers without a screen
Codex on Linux comes as a desktop app (preview: Ubuntu, Debian, Fedora, Arch) and a CLI. Install commands, updates, the sandbox, and signing in on a server.

How to install and update Codex CLI on macOS, Windows and Linux
OpenAI's install and update commands for Codex CLI: script, npm and Homebrew. How to sign in, check the version, and set it up on Windows, WSL and Linux.