You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Frequent reconnect loop in Codex App: websocket closed by server before response.completed #18960
What version of the Codex App are you using (From “About Codex” dialog)?
26.417.41555 (1858)
What subscription do you have?
Pro
What platform is your computer?
macOS
What issue are you seeing?
Over the past few hours, I have repeatedly hit a streaming failure in the Codex App during normal use.
While a response is streaming, the app starts reconnecting multiple times and then fails with:
stream disconnected before completion: websocket closed by server before response.completed
The reconnect sequence I saw included:
Reconnecting... 2/5
Reconnecting... 3/5
Reconnecting... 4/5
Reconnecting... 5/5
This has happened many times within a few hours and makes the app feel noticeably slow and unreliable.
What steps can reproduce the bug?
I do not have a fully deterministic repro yet, but this is the pattern I have observed:
Use the Codex App normally for some time
Send a prompt that produces a streamed response
During streaming, the connection drops unexpectedly
The app shows repeated reconnect attempts
The turn fails before response.completed
This happened multiple times over the last few hours during normal usage.
What is the expected behavior?
The stream should stay connected until the response is fully completed, or the app should recover transparently without losing the response.
Additional information
The failure appears intermittent, but frequent enough to significantly interrupt normal workflow
When it happens, I often have to retry or regenerate
I have a screenshot showing the reconnect loop and exact error text if needed
I also encountered the Reconnecting... problem multiple times within the same task, not just across separate tasks
Based on when I started noticing it, this appears to have been happening since around 1–2 AM US Eastern Time
I am reasonably confident this was not caused by my local network, because my internet connection remained stable and usable throughout the same period
During this same window, Codex also felt unusually slow overall, even when using GPT-5.4 in fast mode
I’m keeping this issue open because this report is specifically about the Codex App on macOS, repeated reconnects within the same task, a stable local internet connection during the failures, and unusually slow overall responses during the same time window even when using GPT-5.4 fast mode.
I’m keeping this issue open because this report is specifically about the Codex App on macOS, repeated reconnects within the same task, a stable local internet connection during the failures, and unusually slow overall responses during the same time window even when using GPT-5.4 fast mode.
it seems that it doesn't really depend on the usage method or the OS.
This is driving me nuts - in codex + vs code codex extension same issue, constantly loosing connection and thinking. burning through requests to just stop and start trying to get it to carry on.
I also encountered "stream disconnected before completion: websocket closed by server before response.completed" issue on macOS Codex. Version 26.616.41845.
Additional reproducible case specific to Codex App multi-agent v2:
Codex App: 26.707.71524 (build 5263)
macOS 26.5.2, arm64
Feature/context: multi_agent_v2 sub-agent in the Codex App
Sub-agent task name: slides_9_15
Workload: inspect six local slide images, run a local command, then continue an image-generation/editing workflow
Observed sequence in the sub-agent card:
"Viewed 6 images"
"Ran command"
"Agent updating"
"Reconnecting ... /5"
stream disconnected before completion: websocket closed by server before response.completed
The parent task remained responsive, but the sub-agent turn never produced a completed response. Any generated result that had not already been persisted locally was effectively lost, and the sub-agent had to be interrupted/restarted.
This seems related to the image-heavy cases already reported here, but adds a multi-agent-v2-specific failure mode: a child-agent stream can die while the parent thread remains usable. Expected behavior is either transparent child-stream recovery/resume, or a terminal child-agent error surfaced to the parent so the coordinator can retry without waiting indefinitely.
Screenshot with the exact reconnect sequence is available.
I was working on a website, and a lot of images were involved. Randomly, the thread died and I got into the compaction disconnect loop. So, I created a new Codex chat and sent the following message:
I am currently getting:
stream disconnected before completion: websocket closed by server before response.completed
My chat seems to have broken. Here is the chat:
codex://threads/<thread ID>
<thread ID>
/Users/<not showing this here>/Documents/Codex/2026-07-18/i
Chat Name: "Create personal track website"
Whenever I send a message, it starts compacting context, and then immediately shows the "Reconnecting ... /5" and it seems to be broken.
Can you please try and repair the chat?
You can get the chat information by right clicking the chat and copying these 3 options:
I used Sol medium for this task, because I wanted to make sure a dumber model like Luna or Terra wouldn't mess anything up. In a few minutes, it found the issue, fixed it, and the chat is back to normal.
Here is what it finished with:
Please give this message a thumbs up if it helped fix the solution for you. Sometimes, the best thing to do is to just let Codex fix its own issue.
Reacted by Lincoln-Muller, AdwayX, MiaoSonglin, leszczy, Soum1111, Philipp Faster-Malkov, exeshka and David Ruiz García
Yes — the cleanup workaround described above helped me recover a task.
My case:
Long-running, image-heavy Codex Desktop task. Every new prompt triggered automatic compaction, then Reconnecting 1/5 through 5/5 and stream disconnected before completion: websocket closed by server before response.completed.
A fork failed too because it inherited the same history.
From a separate healthy task, I inspected the idle rollout: 1.35 GB, containing 254 inline data:image/...;base64,... payloads (~1.35 billion characters).
I backed up the rollout, replaced only custom_tool_call_outputinput_image items containing inline data URLs with small text markers, preserved text/metadata/remote references, validated all 4,594 JSONL records, and atomically replaced the file.
Archive/unarchive was required to make Codex close the old open inode and reload the cleaned rollout. File size dropped to ~6.0 MB.
Two no-tool health checks succeeded. A third check after reload was persisted to the cleaned inode. No reconnect loop.
So in my case this was not a local-network failure: inline screenshots had bloated/poisoned the compaction context. Codex should store these images out-of-line, or exclude/deduplicate them when building compaction input.
and temporarily removed my custom OpenCodex model selection so Codex could use its normal model configuration.
Then I saved config.toml, completely closed/restarted Codex, sent hi, and it immediately worked. No reconnect loop.
So if you're getting error 10061:
Before messing with your firewall, DNS, VPN, router, proxies, reinstalling Codex, etc., check ~/.codex/config.toml.
Search for:
openai_base_url
127.0.0.1
localhost
If openai_base_url is pointing at localhost because of OpenCodex or another third-party tool, and that local service isn't running, that may be the entire problem.
I found at the end that the problem caused by my avast antivirus I opened avast Prefrences/Core Shields / WEB GUARD and add this urls on the exception list
chatgpt.com
openai.com
auth.openai.com
api.openai.com
ab.chatgpt.com
chat.openai.com
oaistatic.com
and also added my codex folder path in the exception list
after that it is too much better
Big thanks to the OpenAI team and all the contributors for the huge amount of work on Codex — the desktop app and the streaming experience are genuinely great when they work. This comment is meant to help narrow down one failure mode, not to pile on 🙂
Same failure on Windows, with transport isolation evidence pointing to the server side
Symptom: turns fail with stream disconnected before completion: websocket closed by server before response.completed (occasionally failed to send websocket request: IO error: ... os error 10054), UI retries 1/5→5/5 and the turn dies. Sporadic since ~Sep 11 (a few per day, retries usually recovered), then persistent for ~8 hours (Sep 19 21:00 → Sep 20 05:15 UTC+8 = Sep 19 09:00–17:15 US Eastern), then recovered on its own.
Isolation tests run during the failure window (all through the same HTTP CONNECT proxy, same account token):
POST https://chatgpt.com/backend-api/codex/responses (SSE over HTTPS): succeeds every time — short requests, a 90 KB / 15 s continuous stream, and an 8 MB upload all complete normally
wss://chatgpt.com/backend-api/codex/responses sessions: connect + upgrade succeed, request is sent, then the server closes the socket mid-stream before response.completed, every attempt, roughly every 12–15 s
Full app restart with a fresh app-server process: does not fix during the window → not stale client state
Auth token valid, no 429s in logs, rate limit not exhausted
Outside the window, the same client reconnects the same websocket through the same path and works fine
This points to server-side (or edge-side) handling of Responses websocket sessions — possibly load- or time-correlated, matching the "starts ~1–2 AM US Eastern" observation upthread — while plain HTTPS streaming on the same endpoint stays healthy.
Workaround (verified): force HTTP transport with a custom provider that disables websockets:
I can now reproduce the failure outside the local interactive CLI path as well.
An independent repository automation/runner that invokes Codex CLI also failed on a minimal probe job with the same general failure pattern:
Codex CLI failed
The probe was intentionally minimal:
no agent message was produced
no business/domain action was invoked
no repository change was made
the failure occurred before any meaningful task execution
The same runner had successfully executed Codex-backed jobs earlier, so this is not a permanently broken runner configuration.
This is important because it means the issue is no longer isolated to my local Windows CLI environment. A separate Codex CLI execution path is now failing on a minimal probe-style job as well.
Current isolation result
The issue therefore persists after:
clean standalone reinstall
removal of duplicate/old Codex installations
fresh ChatGPT authentication
multiple independent networks
confirmed TCP 443 connectivity
IPv6 enabled
no WinHTTP proxy
no OPENAI_* environment variables
healthy codex doctor results
successful WebSocket HTTP 101 handshake
explicit non-WebSocket provider test
fresh sessions with trivial prompts
independent repository-runner Codex probe failure before any business logic or repository modification
The initial connection appears healthy, but Codex is unable to complete the actual response stream.
At this point, the failure appears to affect more than one Codex CLI execution path and looks much more like a service/transport/session issue than a repository, local installation, authentication, proxy, or basic network connectivity problem.
Eu tive um problema recente parecido aparecia para mim:
unexpected status 401 Unauthorized: Incorrect API key provided: sk-svcac***********************************************************************************************************************************************************fvMA. You can find your API key at https://platform.openai.com/account/api-keys., url: https://chatgpt.com/backend-api/codex/responses, cf-ray: regewrtytrutreyutye-GRU, request id: 5y5ggf54-3f444f-5678-46vg-3e453453453
Eu simplemente mudei para o modo ChatGPT dentro do Codex Desktop e depois voltei para o Modo Codex. E voltou a funcionar.
O erro tinha iniciado porque o Codex tentou uma operação com depuração USB e deu falha no meio do processo
Activity
github-actions commentedon Apr 22, 2026
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
GGBondBlueWhale commentedon Apr 22, 2026
I reviewed the duplicates suggested by the bot. They look related, but not like exact duplicates of this report.
I’m keeping this issue open because this report is specifically about the Codex App on macOS, repeated reconnects within the same task, a stable local internet connection during the failures, and unusually slow overall responses during the same time window even when using GPT-5.4 fast mode.
BtcCrush commentedon Apr 22, 2026
加一
zkw13 commentedon Apr 23, 2026
最近两天特别严重,UTC+8 的 14:00~18:00
CaesarC commentedon Apr 23, 2026
+1
shanelindsay commentedon Apr 23, 2026
suspect it is due to system updates to the expected launch of 5.5 later today, servers are flaky
optimusprime123x commentedon Apr 23, 2026
same problem, thread ID thread ID 019dba73-6770-7d90-aac3-6941581fc48b sent feedback twice Codex is becoming unusable for me
kuzkokov commentedon Apr 23, 2026
having the same issue for more than a week now. can't use codex at all now, so I switched to other providers.
was trying it with both codex app and cli on macos — the result is the same.
so, just adding to that:
it seems that it doesn't really depend on the usage method or the OS.
optimusprime123x commentedon Apr 23, 2026
Really hope someone looks into this wtf...
lbqdly commentedon Apr 24, 2026
same problem, Y ?
kukudeshiyi commentedon Apr 26, 2026
and will lose the before threads if i switch to http only mode.....hope can provide a better way as the fallback
36 remaining items
paulchill commentedon Jun 20, 2026
This is driving me nuts - in codex + vs code codex extension same issue, constantly loosing connection and thinking. burning through requests to just stop and start trying to get it to carry on.
Kircerta commentedon Jun 20, 2026
I also encountered "stream disconnected before completion: websocket closed by server before response.completed" issue on macOS Codex. Version 26.616.41845.
hyeluoh commentedon Jun 21, 2026
Guys, I added proxy configuration in ~/.codex/.env, and I haven't seen the reminder to reconnect five times anymore.
adhikary97 commentedon Jul 12, 2026
Still get this issue everyday even for fresh chats
CodeBBakGoSu commentedon Jul 14, 2026
Additional reproducible case specific to Codex App multi-agent v2:
multi_agent_v2sub-agent in the Codex Appslides_9_15Observed sequence in the sub-agent card:
stream disconnected before completion: websocket closed by server before response.completedThe parent task remained responsive, but the sub-agent turn never produced a completed response. Any generated result that had not already been persisted locally was effectively lost, and the sub-agent had to be interrupted/restarted.
This seems related to the image-heavy cases already reported here, but adds a multi-agent-v2-specific failure mode: a child-agent stream can die while the parent thread remains usable. Expected behavior is either transparent child-stream recovery/resume, or a terminal child-agent error surfaced to the parent so the coordinator can retry without waiting indefinitely.
Screenshot with the exact reconnect sequence is available.
Lincoln-Muller commentedon Jul 19, 2026
FOR ANYONE LOOKING FOR THE SOLUTION - READ BELOW!
Hi all, I experienced the same issue.
I was working on a website, and a lot of images were involved. Randomly, the thread died and I got into the compaction disconnect loop. So, I created a new Codex chat and sent the following message:
You can get the chat information by right clicking the chat and copying these 3 options:
I used Sol medium for this task, because I wanted to make sure a dumber model like Luna or Terra wouldn't mess anything up. In a few minutes, it found the issue, fixed it, and the chat is back to normal.
Here is what it finished with:

Please give this message a thumbs up if it helped fix the solution for you. Sometimes, the best thing to do is to just let Codex fix its own issue.
LukasWillin commentedon Jul 21, 2026
I seemed to be able to mostly "fix" / work around this issue by following this link (https://learn.chatgpt.com/docs/config-file/config-advanced#azure-provider-and-per-provider-tuning) and setting:
I don't know however if this works outside the Azure AI Foundry provider.
maybephilipp commentedon Aug 21, 2026
@Lincoln-Muller thank you! #18960 (comment)
Yes — the cleanup workaround described above helped me recover a task.
My case:
Reconnecting 1/5through5/5andstream disconnected before completion: websocket closed by server before response.completed.data:image/...;base64,...payloads (~1.35 billion characters).custom_tool_call_outputinput_imageitems containing inline data URLs with small text markers, preserved text/metadata/remote references, validated all 4,594 JSONL records, and atomically replaced the file.So in my case this was not a local-network failure: inline screenshots had bloated/poisoned the compaction context. Codex should store these images out-of-line, or exclude/deduplicate them when building compaction input.
timbehrens12 commentedon Sep 4, 2026
I finally fixed this after thinking Codex/networking was completely broken.
My Codex app would repeatedly show:
Reconnecting... waiting for network
Eventually it would reach Reconnecting 5/5 and show:
stream disconnected before completion: No connection could be made because the target machine actively refused it. (os error 10061)
My internet was fine. chatgpt.com:443 was reachable, reinstalling/restarting didn't solve it, and Windows had no system proxy configured.
The actual problem was my Codex config.
Open this file on Windows:
C:\Users<YOUR_USERNAME>.codex\config.toml
Or from PowerShell:
notepad $env:USERPROFILE.codex\config.toml
In my config I found:
Auto-injected by opencodex
openai_base_url = "http://127.0.0.1:10100/v1"
I had previously used OpenCodex, and it had modified my Codex configuration to route OpenAI requests through a local server at:
127.0.0.1:10100
That local server was no longer running.
So instead of the official Codex app connecting normally to OpenAI, it was trying to connect to a dead localhost endpoint. Windows therefore returned:
os error 10061
which means the connection was actively refused.
FIX
I removed this from config.toml:
Auto-injected by opencodex
openai_base_url = "http://127.0.0.1:10100/v1"
I also removed the OpenCodex custom model catalog:
model_catalog_json = "C:\Users\\.codex\opencodex-catalog.json"
and temporarily removed my custom OpenCodex model selection so Codex could use its normal model configuration.
Then I saved config.toml, completely closed/restarted Codex, sent hi, and it immediately worked. No reconnect loop.
So if you're getting error 10061:
Before messing with your firewall, DNS, VPN, router, proxies, reinstalling Codex, etc., check ~/.codex/config.toml.
Search for:
openai_base_url
127.0.0.1
localhost
If openai_base_url is pointing at localhost because of OpenCodex or another third-party tool, and that local service isn't running, that may be the entire problem.
In my case, this:
openai_base_url = "http://127.0.0.1:10100/v1"
was 100% the cause of Codex repeatedly reconnecting and throwing Windows error 10061.
ibrahimelkady2001 commentedon Sep 6, 2026
I found at the end that the problem caused by my avast antivirus I opened avast Prefrences/Core Shields / WEB GUARD and add this urls on the exception list
chatgpt.com
openai.com
auth.openai.com
api.openai.com
ab.chatgpt.com
chat.openai.com
oaistatic.com
and also added my codex folder path in the exception list
after that it is too much better
ogpinkfloyd-stack commentedon Sep 10, 2026
bump
1000water commentedon Sep 19, 2026
Big thanks to the OpenAI team and all the contributors for the huge amount of work on Codex — the desktop app and the streaming experience are genuinely great when they work. This comment is meant to help narrow down one failure mode, not to pile on 🙂
Same failure on Windows, with transport isolation evidence pointing to the server side
Environment: Codex Desktop 26.915.4065.0 / codex-cli 0.155.0-alpha.9.2, Windows 10, ChatGPT account auth.
Symptom: turns fail with
stream disconnected before completion: websocket closed by server before response.completed(occasionallyfailed to send websocket request: IO error: ... os error 10054), UI retries 1/5→5/5 and the turn dies. Sporadic since ~Sep 11 (a few per day, retries usually recovered), then persistent for ~8 hours (Sep 19 21:00 → Sep 20 05:15 UTC+8 = Sep 19 09:00–17:15 US Eastern), then recovered on its own.Isolation tests run during the failure window (all through the same HTTP CONNECT proxy, same account token):
POST https://chatgpt.com/backend-api/codex/responses(SSE over HTTPS): succeeds every time — short requests, a 90 KB / 15 s continuous stream, and an 8 MB upload all complete normallywss://chatgpt.com/backend-api/codex/responsessessions: connect + upgrade succeed, request is sent, then the server closes the socket mid-stream beforeresponse.completed, every attempt, roughly every 12–15 sThis points to server-side (or edge-side) handling of Responses websocket sessions — possibly load- or time-correlated, matching the "starts ~1–2 AM US Eastern" observation upthread — while plain HTTPS streaming on the same endpoint stays healthy.
Workaround (verified): force HTTP transport with a custom provider that disables websockets:
Hope the isolation data helps. Thanks again for the great work on this project!
buffbuffdev commentedon Sep 25, 2026
I can reproduce a very similar issue on Windows 11 with Codex CLI 0.157.0 and ChatGPT authentication.
Minimal reproduction
codex exec "Reply only OK"Actual behavior
Codex starts normally, but the request immediately enters a reconnect loop:
On some attempts, Codex then reports:
I also sometimes get:
The request never completes.
Expected behavior
The trivial request should complete normally and return:
Troubleshooting already performed
I have already tested all of the following:
0.153.1to0.157.0OPENAI_*environment variables are setchatgpt.comis reachablecodex doctorreports healthy authentication and local statecodex doctorsuccessfully establishes the WebSocket handshake withHTTP 101 Switching ProtocolsSo the initial WebSocket connection succeeds, but the actual response stream disconnects before
response.completed.This does not appear to be repository-specific, authentication-specific, or network-specific.
Non-WebSocket isolation test
I also tested forcing Codex to use a custom provider with WebSockets explicitly disabled:
Codex correctly recognized the custom provider:
However, even a trivial fresh request still immediately entered:
So forcing the custom HTTPS/non-WebSocket provider did not resolve the issue on Codex CLI 0.157.0.
I restored the normal OpenAI provider afterward.
I also checked the Codex configuration for suspicious overrides such as:
and found none.
Additional isolation from an independent runner
I can now reproduce the failure outside the local interactive CLI path as well.
An independent repository automation/runner that invokes Codex CLI also failed on a minimal probe job with the same general failure pattern:
The probe was intentionally minimal:
The same runner had successfully executed Codex-backed jobs earlier, so this is not a permanently broken runner configuration.
This is important because it means the issue is no longer isolated to my local Windows CLI environment. A separate Codex CLI execution path is now failing on a minimal probe-style job as well.
Current isolation result
The issue therefore persists after:
OPENAI_*environment variablescodex doctorresultsHTTP 101handshakeThe initial connection appears healthy, but Codex is unable to complete the actual response stream.
At this point, the failure appears to affect more than one Codex CLI execution path and looks much more like a service/transport/session issue than a repository, local installation, authentication, proxy, or basic network connectivity problem.
safdar-azeem commentedon Sep 25, 2026
The problem was stale environment variables overriding Codex's ChatGPT authentication.
Quit Codex completely, then run:
unset OPENAI_API_KEY CODEX_API_KEY OPENAI_BASE_URL CODEX_ACCESS_TOKEN launchctl unsetenv OPENAI_API_KEY launchctl unsetenv CODEX_API_KEY launchctl unsetenv OPENAI_BASE_URL launchctl unsetenv CODEX_ACCESS_TOKENThen reopen Codex. It started working immediately for me.
If the issue returns, also check ~/.zshrc, ~/.zprofile, etc. for those variables.
indiobranco commentedon Sep 26, 2026
Eu tive um problema recente parecido aparecia para mim:
unexpected status 401 Unauthorized: Incorrect API key provided: sk-svcac***********************************************************************************************************************************************************fvMA. You can find your API key at https://platform.openai.com/account/api-keys., url: https://chatgpt.com/backend-api/codex/responses, cf-ray: regewrtytrutreyutye-GRU, request id: 5y5ggf54-3f444f-5678-46vg-3e453453453
Eu simplemente mudei para o modo ChatGPT dentro do Codex Desktop e depois voltei para o Modo Codex. E voltou a funcionar.
O erro tinha iniciado porque o Codex tentou uma operação com depuração USB e deu falha no meio do processo