🔌

Codex: Stream Disconnected Before Completion

'stream disconnected before completion' means the response stream for a Codex turn ended before the model sent its final 'response.completed' event. Codex retries automatically (you see 'Reconnecting... 1/5' through '5/5') and only shows the error when every retry fails. The text after the colon tells you which kind of break it was. 'Transport error: network error: error decoding response body' means the connection dropped or returned something Codex could not parse partway through the answer. 'stream closed before response.completed' means the server or something in between closed the stream early. 'failed to send websocket request: io error ... (os error 10054)' is a Windows message meaning the remote host forcibly closed the connection, which usually points at a proxy, VPN, antivirus or firewall interrupting Codex's WebSocket traffic. These errors appear most often on long turns in large repositories, during OpenAI incidents, and on networks that do not pass WebSocket traffic cleanly. Your files are not rolled back when the stream breaks, so the first job is to check what was already changed, then retry in a way that gives the stream a better chance of finishing.

Recommended toolMercorGet paid to use your expertise training and evaluating AI for leading AI labs.Join Mercor

Affiliate link, we may earn a commission at no extra cost to you.

Symptoms You Might See

⚠️

Codex shows 'Reconnecting... 1/5' up to '5/5' and then stops the turn

⚠️

The final message reads 'stream disconnected before completion' followed by a transport or websocket error

⚠️

Long refactors or repository-wide tasks fail while short prompts still work

⚠️

The same thread keeps failing even after you retry

⚠️

'Falling back from WebSockets to HTTPS transport' appears before the failure

⚠️

On Windows the error ends with 'os error 10054'

Common Causes

OpenAI-side incident or capacity pressure

When OpenAI's Codex backend is degraded, streams are dropped mid-answer for many users at once. GitHub issues for this exact error spike during incidents and are fixed server-side, so check status before changing anything locally.

Very long turns in a large repository

A turn that reads many files, runs long commands and writes a long final report keeps the stream open for a long time. The longer a single stream stays open, the more chances a network hiccup has to break it. Reports on the Codex repository consistently describe long tasks in big repos as the trigger.

Proxy, VPN or firewall breaking WebSocket traffic

Codex prefers a WebSocket connection over port 443 and falls back to HTTPS when that fails. Corporate proxies, TLS inspection, some VPNs and security software close or alter long-lived connections, which produces the 'error decoding response body' and 'os error 10054' variants.

An oversized conversation

If the actual message mentions the context window (for example 'your input exceeds the context window'), the problem is not the network: the thread has grown too large. A plain transport error does not prove this, so read the full message.

Outdated Codex client

Transport and retry handling changes between Codex releases. An old CLI, IDE extension or desktop app can mis-handle a stream that a newer build recovers from.

Step-by-Step Fixes

1

Check OpenAI status first

When to try: First, especially if it started suddenly

Open status.openai.com and look at the Codex component. If there is an active incident, wait for it to resolve rather than retrying the same long task repeatedly, which only burns usage.

2

Review what already changed before retrying

When to try: Before any retry on a task that edits files

A broken stream does not undo edits Codex already made. Run git status and git diff --stat to see the current state of your working tree so the retry does not redo or duplicate completed changes.

3

Retry with a smaller, scoped request

When to try: When long tasks fail but short prompts succeed

Instead of 'analyze the repo, implement the fix, run validation and report', split the work: first ask for the change in named files, then ask for tests in a separate turn. Shorter turns keep each stream open for less time.

4

Start a fresh thread with a checkpoint

When to try: When the same thread fails repeatedly

If one thread keeps failing, write a short checkpoint (goal, what is done, what remains, which files matter), run /new in the CLI or open a new chat in the app, and paste the checkpoint. Users on the Codex issue tracker report this as the most reliable recovery when a thread is stuck.

5

Test the network path without proxies

When to try: When you see os error 10054 or HTTPS fallback messages

Disconnect the VPN, pause TLS-inspecting security software, or try a different network such as a phone hotspot. If Codex works there, your usual network is interrupting WebSocket traffic; ask IT to allow long-lived WebSocket connections to chatgpt.com and api.openai.com on port 443.

6

Update Codex

When to try: If you have not updated in the last few weeks

Update the CLI (for example with npm install -g @openai/codex@latest or your package manager), the IDE extension and the desktop app, then restart them. Run codex --version to confirm the new build is the one in use.

7

Report it with diagnostics

When to try: When nothing above works

If it persists with no incident on the status page, run /feedback in Codex to upload logs and file an issue on github.com/openai/codex with your version, OS, model, the time, and a short redacted error excerpt. Never paste auth.json or API keys.

How to Prevent This

✓

Keep each request to one clear outcome instead of a whole project in one turn

✓

Commit or stash before long Codex tasks so you can see exactly what changed

✓

Start new threads per task rather than reusing one very long conversation

✓

Keep Codex updated, and use a network that allows WebSocket traffic

When to Contact Support

Contact OpenAI (or open a GitHub issue for the CLI) when the error continues for hours with no incident on status.openai.com, happens on short prompts on a clean network, or happens on every thread. Include your Codex version, operating system, model, approximate times, and the feedback ID from /feedback.

Frequently Asked Questions

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

The response stream for a Codex turn ended before the model sent its final completion event. Codex retried up to five times and then gave up. The text after the colon tells you whether it was a transport error, an early close, or a WebSocket failure.

What does 'error decoding response body' mean?▼

The connection dropped or returned data Codex could not parse partway through the answer. It is usually a network interruption or an OpenAI-side incident, not a problem with your code or prompt.

Did I lose my changes when the stream disconnected?▼

No. Edits Codex already wrote to disk stay in your working tree. Check git status and git diff before retrying so the next attempt continues from the current state.

What is os error 10054 in Codex?▼

It is a Windows error meaning the remote host forcibly closed the connection. With Codex it usually means a proxy, VPN, firewall or antivirus closed the WebSocket. Try another network or ask IT to allow WebSocket traffic to OpenAI on port 443.

Is this the same as running out of context?▼

Not necessarily. Only treat it as a context problem if the message mentions the context window. A plain transport error is a connection problem; an oversized thread gives a different message and needs /compact or a new thread.

Other Common AI Errors

⚠️

ChatGPT Not Working

Service Issues

🚦

Rate Limit Exceeded

Usage Limits

📏

Context Length Exceeded

Input Limits

🔥

Model Overloaded

Service Issues

Don't stop here

What to read next

Hand-picked guides our readers explore right after this one.