Short answer
stream disconnected before completion means the response stream for a Codex turn ended, or failed, after the request was accepted but before the model's response finished. It isn't one specific error. Codex puts the real reason after the colon, and that part tells you what to do:
No card at all? You can also top up with USDT, USDC or ETH: click Pay with crypto in the top-up dialog and send it from Binance, OKX or any wallet. The minimum is $5 and no browser extension is needed. Step by step: Pay for Claude and GPT APIs with crypto (USDT).
| Text after the colon | What it points to |
|---|---|
error sending request for url (...), os error 10053, os error 10061, os error 61, Broken pipe (os error 32) |
Your network, VPN, proxy or firewall |
stream closed before response.completed |
The connection closed mid-response, somewhere between you and the server |
websocket closed by server before response.completed |
The server closed Codex's WebSocket before the response finished; usually on OpenAI's side, sometimes a proxy |
idle timeout waiting for SSE / idle timeout waiting for websocket |
No data arrived for the idle timeout (5 minutes by default) |
regurg plugin blocked the output stream. |
OpenAI's servers blocked the model's output (HTTP 400 safety_violation); not a network problem |
An error occurred while processing your request. ... request ID ... |
An error on the server side |
Our servers are currently overloaded. Please try again later. |
The model is at capacity |
Rate limit reached for ... / Request too large for ... |
A tokens-per-minute or requests-per-minute limit |
Codex retries on its own first, which is the Reconnecting... 1/5 line you see before the error. If the error comes back once in a while, retrying the turn is fine. If it comes back every time, use the text after the colon to find the cause.
What the error looks like
The message is defined in Codex's source (codex-rs/protocol/src/error.rs) as stream disconnected before completion: {reason}, for a stream that disconnects or errors after the HTTP handshake succeeded but before response.completed. Codex treats it as transient and retries the turn.
While retrying, you see a counter, as in openai/codex#47538:
Reconnecting... 1/5 (stream disconnected before completion: stream closed before response.completed)
When the retries run out, Codex may switch from WebSockets to HTTPS and try again (#38366, shortened):
⚠ Falling back from WebSockets to HTTPS transport. stream disconnected before completion: Request too large for gpt-5.6-luna in organization org-... on tokens per min (TPM): Limit 200000, Requested 208334. The input or output tokens must be reduced in order to run successfully.
Other reasons reported in the Codex issue tracker:
stream disconnected before completion: error sending request for url (https://chatgpt.com/backend-api/codex/responses)
stream disconnected before completion: IO error: An established connection was aborted by the software in your host machine. (os error 10053)
stream disconnected before completion: No connection could be made because the target machine actively refused it. (os error 10061)
stream disconnected before completion: websocket closed by server before response.completed
stream disconnected before completion: idle timeout waiting for SSE
stream disconnected before completion: idle timeout waiting for websocket
stream disconnected before completion: IO error: Broken pipe (os error 32)
stream disconnected before completion: Connection refused (os error 61)
stream disconnected before completion: regurg plugin blocked the output stream.
stream disconnected before completion: Our servers are currently overloaded. Please try again later.
stream disconnected before completion: An error occurred while processing your request. You can retry your request, or contact us through our help center at help.openai.com if the error persists. Please include the request ID <id> in your message.
Sources: #38212, #54459, #49466, #53578, #53557, #18960, #46149, #51039, #56387, #38885 and #51937.
The URL in a message also tells you which endpoint Codex was using: chatgpt.com/backend-api/codex/... when you're signed in with ChatGPT, api.openai.com/v1/... with an OpenAI API key, or your provider's base_url with a custom provider.
Causes and fixes by reason
Network: error sending request, os error 10053, os error 10061, os error 61, os error 32
Codex couldn't send the request, or your machine closed the connection.
os error 10061(connection refused) on Windows. Nothing answered at the address Codex tried. If Codex goes through a local proxy, check that the proxy is running and listening on the port Codex uses, or remove the setting that points Codex at it.os error 10053on Windows. Software on your machine aborted the connection: a firewall, antivirus, VPN client or proxy. Test with them paused, then add an exception for Codex.os error 61(connection refused) on macOS. The macOS version of 10061 (on Linux it isos error 111). The usual cause is a local proxy that is no longer running. In #38885, Codex kept sending traffic to127.0.0.1:7890because a forgotten~/.codex/.envfile setHTTP_PROXY,HTTPS_PROXYandALL_PROXY; the proxy app had been closed. Check that file and your shell's proxy variables, then start the proxy or remove the settings.Broken pipe (os error 32)on macOS and Linux. The other side closed the connection while Codex was still sending. A proxy or VPN dropping the connection is one cause; very large requests are another: in an image-heavy chat, one user measured that OpenAI's WebSocket endpoint rejects messages above about 16 MiB (#55317). If only one long thread keeps failing while new threads work (#56387), start a new thread or leave the large images out; if every request fails, check your proxy or VPN.error sending request for url. DNS, proxy or network failure before the request got out. Check that the host in the URL resolves and is reachable from the same terminal.
Run codex doctor to see the environment Codex is running in. Then test the host from the URL in the message from the same terminal, for example curl -I https://chatgpt.com or curl -I https://api.openai.com/v1/models. Any HTTP status means the host is reachable; a connection error means the network path is the problem, not Codex.
WebSocket closed: websocket closed by server before response.completed
When you're signed in with ChatGPT, Codex streams each response over a WebSocket to wss://chatgpt.com/backend-api/codex/responses. This message means the server closed that connection before the final response.completed event. Codex retries up to five times (Reconnecting... 2/5 to 5/5), may fall back to HTTPS (Falling back from WebSockets to HTTPS transport), and shows the error if every attempt fails.
People report it from both the CLI and the desktop app, with and without a VPN (#18960, #20739, #13041), so it is often on OpenAI's side.
- Retry the turn. A one-off drop usually goes through on the next attempt.
- If you use a proxy app (Clash and similar), make sure Codex uses it for WebSocket traffic too. Several people in #18960 and #13041 fixed the reconnect loop by setting
HTTPS_PROXY,HTTP_PROXYand, for SOCKS5,ALL_PROXYin~/.codex/.env. - Update Codex with
npm install -g @openai/codex@latest. - If it keeps happening, add your thread ID to #18960 or report it with
/feedback.
A custom provider sends requests to its own base_url instead of chatgpt.com, so this particular endpoint isn't involved; see Using Codex with a TeamoRouter key below.
Mid-stream drop: stream closed before response.completed
The response had started, then the connection closed before the final event. Anything between you and the server can do this: an unstable Wi-Fi link, a VPN switching nodes, a proxy that cuts long connections, or the server itself.
- If it happens now and then, let Codex retry, or send the turn again.
- If it happens often on one network, try another network or test without the VPN or proxy.
- If you use a custom provider or gateway, check its logs for the request. A gateway in the middle can close the stream too.
Idle timeout: idle timeout waiting for SSE
No events arrived on the stream for the idle timeout. Long reasoning or a stalled connection can cause it. For a custom provider, the timeout is stream_idle_timeout_ms (default 300000, which is 5 minutes) in the provider's block in ~/.codex/config.toml, per the configuration reference.
Idle timeout: idle timeout waiting for websocket
The same timeout on the WebSocket connection Codex uses for OpenAI's Responses API: no message arrived within the idle timeout. In Codex's source (responses_websocket.rs) it uses the same provider setting as the SSE path, stream_idle_timeout_ms. One report traced it to a turn that stayed silent for about 300 seconds while a tool call was being dispatched (#51039); Codex reconnected and continued on its own. If it happens on every turn, treat it like the network causes above.
Server error: An error occurred while processing your request
The server returned an error after the stream had started. Retry the turn. If it keeps happening, report it with /feedback and include the request ID from the message.
Our servers are currently overloaded. Please try again later. usually comes with Selected model is at capacity. Please try a different model. (#46149). Switch to another model with /model, or wait a few minutes and retry.
Reports often cluster: #45949, #45965, #46161 and #46248 were all filed on September 16–17, 2026. In #45925, one user measured a failure rate that changed with the ChatGPT account they were signed in with, on the same machine and network. If your setup didn't change and the error started suddenly, check the issue tracker before you change anything locally.
Rate limit or request size: Rate limit reached / Request too large
The text names a tokens-per-minute (TPM) or requests-per-minute (RPM) limit.
Rate limit reached for ... Please try again in 13.694s(#10060) is temporary. Wait the stated time.Request too large for ... The input or output tokens must be reduced in order to run successfully.means one request is bigger than the whole per-minute limit, so waiting won't help. In #38366, Codex kept resending a 208K-token request against a 200K TPM limit. Start a new thread, or run/compactto shrink the conversation.
For the API-side details, see OpenAI API 429 "Rate limit reached".
Output blocked: regurg plugin blocked the output stream
This one is not a network problem. The full error is HTTP 400 with code safety_violation and the message regurg plugin blocked the output stream. (#51937). The text isn't in Codex's source: it comes from OpenAI's servers, where a filter stopped the model's output partway through. OpenAI hasn't documented this filter, and there was no reply from OpenAI in the GitHub threads as of October 26, 2026.
Since early October 2026 it has been reported in the CLI and the desktop app on Windows, macOS and Linux, with GPT-6.1 Sol, GPT-6 Astra and GPT-5.6 Sol (#52600, #54966). Reports agree that it depends on the task: retrying the same request in the same thread usually fails again, while unrelated tasks work. Some users saw it even in a new thread (#54818). What users say helped:
- Ask for the work in a different form or in smaller steps, in a new thread.
- Switch model with
/model; one user got past it by moving from GPT-6.1 Sol to GPT-5.6 Sol.
Tune retries and timeouts for a custom provider
When Codex uses a provider you define under [model_providers.<id>], you can set these keys in its block. Defaults are from the configuration reference; the advanced configuration page has an example:
| Key | Default | What it does |
|---|---|---|
request_max_retries |
4 | Retries for the HTTP request to the provider |
stream_max_retries |
5 | Retries after the stream is interrupted |
stream_idle_timeout_ms |
300000 | How long a stream may stay silent before Codex treats it as dead |
More retries help on a network that drops connections now and then. They don't help when the reason is a request that's too large, or a setting that's wrong.
Using Codex with a TeamoRouter key
TeamoRouter is an API gateway with one key for GPT, Claude, Gemini and DeepSeek. It speaks the OpenAI Responses API (/v1/responses), so Codex connects to it as a custom provider. There's no subscription; you pay per use.
- Create an API key in the TeamoRouter console. It starts with
sk-teamo-. - Top up from $5. The top-up dialog takes cards. You can also click Pay with crypto and pay with USDT, USDC or ETH from any exchange app — the checkout shows which networks your amount supports (BEP20 works from $5). Step by step: Pay with USDT.
- Add the provider to
~/.codex/config.toml. The last two lines are optional:
model_provider = "teamorouter"
model = "gpt-6-sol"
[model_providers.teamorouter]
name = "TeamoRouter"
base_url = "https://api.teamorouter.ai/v1"
env_key = "OPENAI_API_KEY"
wire_api = "responses"
stream_max_retries = 10
stream_idle_timeout_ms = 300000
- Set the key and test the path from the terminal you'll run Codex in:
export OPENAI_API_KEY="sk-teamo-..."
curl https://api.teamorouter.ai/v1/models \
-H "Authorization: Bearer $OPENAI_API_KEY"
A model list means the path and key work. Start codex from the same shell. Windows commands are in Install and connect Codex. For the gpt-6-sol model in that config, see GPT-6 Sol API pricing and Codex CLI setup.
FAQ
Is "stream disconnected" a network problem?
Sometimes. It's a wrapper around many reasons. Read the text after the colon: os error codes and error sending request are network problems, while Rate limit reached and An error occurred while processing your request are not.
Does Codex retry automatically?
Yes. The Reconnecting... N/5 line is Codex retrying. After the retries, it may fall back from WebSockets to HTTPS before showing the error.
Will logging out and back in fix it? Not for network or rate-limit reasons. It only matters if the problem follows your account, as reported in #45925.
Why does it happen during "remote compact task"?
Compaction is a request too, so it can fail for the same reasons. A message such as Error running remote compact task: stream disconnected before completion: ... has the reason after the second colon.