Skip to content

Codex Keeps Reconnecting? What "Waiting for Network" and 5/5 Mean

"Waiting for network" retries until Codex can reach chatgpt.com again; 1/5 to 5/5 retries a cut-off reply five times, then falls back to HTTPS or stops.

•••14 min read•OpenAI Codex
Two Codex reconnect messages side by side: Reconnecting... waiting for network means no connection and retries with no limit; Reconnecting... 5/5 means a reply was cut off and is retried up to 5 times

Reconnecting tells you that Codex lost a connection it is trying to recover. It does not tell you whether the problem affects the current task, the client, authentication, the network path, or a temporary service interruption. The line printed with it narrows that down, because Codex runs two different retry loops:

What Codex showsWhat it meansFirst step
Reconnecting... waiting for network, then Connection failed: error sending requestThe Codex process could not open a connection to chatgpt.com at all. Since CLI 0.148.0 (August 18, 2026), Codex keeps the turn alive and retries with no limit, waiting 5 seconds, then 10, 20, 40 and 60 seconds between attempts. There is no counter, so it never reaches 5/5.Test the network from the machine that runs Codex
Reconnecting... 2/5 through 5/5 (the desktop app shows Reconnecting 5/5)A reply that had started streaming was cut off. Codex retries it up to 5 times, with a few seconds of waiting in total unless the server asks for longer. The first WebSocket retry is not shown, so 2/5 is often the first number you see.Let it finish. Read the line that follows 5/5.
Falling back from WebSockets to HTTPS transport.The retries ran out on the WebSocket connection, so Codex switched the session to plain HTTPS and started counting again.Usually nothing. Repeated fallbacks point to something that interferes with WebSockets on your network.
stream disconnected before completion: …The final error: the retries are used up and the turn has stopped. The text after the colon says where it broke.Save the task state, then read the reason.
Server is busy, reconnecting 2/5 (CLI 0.168.0 and later)The stream got HTTP 429: the server is overloaded or a limit applies. Your network is fine.See the Codex 429 guide.
Reconnecting to server… (terminal UI)The terminal UI lost its link to a Codex background server it was attached to. This is not the model stream.Wait for it to reconnect on its own (CLI 0.153.0 and later).

These texts come from the Codex source and the 0.148.0 release notes. Builds older than 0.148.0 counted the same connection failure from 1/5 to 5/5 and ended with stream disconnected before completion: error sending request for url (https://chatgpt.com/backend-api/codex/responses ), the form quoted in GitHub issue #13245 in March 2026. Newer builds strip the URL from the message.

The two Codex retry loops: Reconnecting... waiting for network with Connection failed: error sending request waits 5, 10, 20, 40 and 60 seconds with no limit, while Reconnecting... 2/5 to 5/5 retries a cut-off reply, falls back from WebSockets to HTTPS, then ends with stream disconnected before completion

If the desktop app says Codex app-server is not available instead of Reconnecting, the failure is the local background process or the dot task's cloud connection; see why Codex says app-server is not available.

That distinction matters before you act. Deleting ~/.codex, clearing every session, signing out, changing models, and rewriting proxy settings at the same time can erase the evidence that would have separated those causes. Your repository changes usually remain on disk, but an unfinished task can still contain the prompt, approvals, tool output, and last confirmed step you need to resume safely.

If the sequence reaches Reconnecting 5/5 and ends with:

text
stream disconnected before completion

copy the last instruction, list the files Codex was working on, and note the last completed action. Do not immediately resend an instruction that creates an external side effect. A delayed request may still finish after the UI reconnects.

Start with three quick checks

Leave the affected task intact and run three small checks:

  1. Start a new task in the same project with a read-only request, such as asking Codex to identify the current directory.
  2. Open the integrated terminal and run pwd or git status.
  3. If you have another Codex client installed, send an equally small read-only request through the CLI or IDE extension.

These observations split the problem more reliably than a generic fix:

What worksWhat the result narrowsSafest next move
A new task works, but the old one reconnectsThe saved task or its response streamContinue from a concise handoff in the new task; retain the old task for diagnostics
CLI works, but Desktop does notDesktop build, host process, or its routeCompare versions, then fully quit and reopen Desktop
Terminal commands work, but every Codex client failsThe project shell is not the primary blockerCheck authentication, client versions, service status, and one network comparison
git status also hangsLocal repository, filesystem, shell, or process stateInvestigate the local command failure before treating reconnecting as the sole issue
Multiple clients fail on two approved networksAccount, service, or broad client failure becomes more plausibleStop changing local state and prepare a diagnostic report

OpenAI's official troubleshooting guide uses the same low-risk signals for stuck states: check whether Codex is waiting for an approval, run a basic terminal command, and try a smaller focused chat. None requires deleting the original task.

Record the version for each client

For the CLI, run:

bash
codex --version
codex --help

Use the About screen for Desktop and the extension details page for the IDE. “Latest Codex” is not a useful version record: OpenAI notes that the desktop app and CLI can carry different Codex versions, and IDE releases have their own cadence. The desktop app reports its own build number (for example 26.1013.40934), not the CLI version.

Updating is a rational early step because reconnect behavior has changed in releases. The official ChatGPT and Codex changelog says Codex CLI 0.148.0 added recovery through temporary provider outages. The same date's app notes describe fixes for tasks that remained unavailable after being idle or reconnecting. The CLI releases since then that touch reconnecting, WebSockets, retries, or proxies, from the openai/codex release notes:

CLI version (release date, 2026)Change
0.148.0 (August 18)Connection failures show Reconnecting... waiting for network and retry until the network returns (#37485, #38601)
0.149.0 (August 20)codex doctor diagnoses network and proxy failures
0.153.0 (September 3)The terminal UI reconnects after its background-server connection drops, keeping drafts (#41916)
0.156.0 (September 22)Throttling and quota errors are classified correctly for retries (#45602); ChatGPT cookies are shared between HTTP and WebSocket connections (#46506)
0.161.0 and 0.162.0 (October 7–8)Retries and the WebSocket-to-HTTPS fallback respect the server's Retry-After advice (#49441, #50418, #51440)
0.164.0 (October 23)On Windows, HTTPS and WebSocket connections answer proxy authentication challenges with the signed-in user's Negotiate or NTLM credentials (#55994, #56000)
0.166.0 (October 29)codex doctor --network-only checks config, proxy environment, provider HTTP and a WebSocket handshake (#57606); better terminal reconnect recovery (#57820)
0.167.0 (November 6)System proxy support can be turned on from /experimental (#58157)
0.168.0 (November 13)WebSocket transport recovers after a temporary HTTPS fallback (#58950); HTTP 429 shows Server is busy, reconnecting (#59253)
0.169.0 (November 13)Stale cloud stream disconnects are no longer shown after reopening a thread (#60327); invalid-workspace errors stop retrying (#60475)

That history supports “compare and update.” It does not support “an old version is always the cause.” After an update, repeat the same small task before changing anything else so the outcome remains attributable.

Route explicit errors before testing the network

error sending request can come from two different connections, so read the entire error, not only the reconnect counter:

  • Connection failed: error sending request under Reconnecting... waiting for network is the model stream to chatgpt.com, covered in the network section below.
  • Token exchange failed: error sending request for url (https://auth.openai.com/oauth/token ) or access token could not be refreshed happens at sign-in and belongs to the Codex token-refresh guide.
  • HTTP 429, Server is busy, reconnecting, a usage limit, or a reset time belongs to the Codex rate-limit diagnostic.
  • A named command, MCP server, or cloud config bundle timing out needs the component-specific checks in the Codex timeout guide.
  • A failure that names remote compaction in a long thread belongs to the Codex remote compact guide.
  • self signed certificate in certificate chain or another certificate error belongs to the Codex certificate guide.
  • A plain response-stream disconnect with repeated reconnect attempts remains a client-stream problem until stronger evidence narrows it.

Do not sign out solely because of a generic stream interruption. Logout changes the authentication state and can turn one unknown into two. If the message explicitly identifies authentication, record the original text and then test the documented sign-in flow.

Test one network condition, on the actual host

Reconnecting... waiting for network followed by Connection failed: error sending request means the Codex process itself could not open a connection to chatgpt.com. A browser reaching ChatGPT proves only that the browser's route works. Codex Desktop, a terminal, a VS Code extension host, WSL, a container, Remote SSH, and a corporate VM can use different DNS, certificate stores, proxies, or firewall policy. Identify where the Codex process actually runs before testing connectivity.

Codex streams model replies over a WebSocket to wss://chatgpt.com/ on TCP port 443, according to OpenAI's network recommendations. A proxy, firewall, or secure web gateway has to allow the Upgrade: websocket handshake, and TLS inspection must not block, rewrite, or close that long-running connection early. On March 2, 2026, a Codex maintainer replying in issue #13245 described this error as "a basic network connectivity issue," seen often with VPNs and proxies.

Run these checks where Codex runs

On macOS or Linux, in the same terminal (or WSL, container, or SSH session) that runs Codex:

bash
# 1. Proxy variables this shell passes to Codex
env | grep -i '_proxy'

# 2. Proxy settings or a custom endpoint that Codex loads at startup
grep -i 'proxy' ~/.codex/.env
grep -n 'openai_base_url' ~/.codex/config.toml

# 3. Can this machine reach the Codex endpoint over HTTPS?
curl -sS -o /dev/null -w '%{http_code}\n' https://chatgpt.com/backend-api/codex/responses

# 4. If a proxy variable names a local port, is anything listening there?
lsof -nP -iTCP:PORT -sTCP:LISTEN

On Windows, in PowerShell (use curl.exe, because curl is an alias for Invoke-WebRequest in Windows PowerShell):

powershell
# 1. Proxy variables in this session, and the system WinHTTP proxy
Get-ChildItem Env: | Where-Object Name -match 'proxy'
netsh winhttp show proxy

# 2. Proxy settings or a custom endpoint that Codex loads at startup
Select-String -Path "$env:USERPROFILE\.codex\.env", "$env:USERPROFILE\.codex\config.toml" -Pattern 'proxy', 'openai_base_url' -ErrorAction SilentlyContinue

# 3. TCP first, then HTTPS with TLS details
Test-NetConnection chatgpt.com -Port 443
curl.exe -sS -o NUL -w '%{http_code}\n' https://chatgpt.com/backend-api/codex/responses
curl.exe -Iv https://chatgpt.com

# 4. If a proxy variable names a local port, is anything listening there?
Get-NetTCPConnection -State Listen -LocalPort PORT

Replace PORT with the port number from the proxy variable. If you set CODEX_HOME, look in that folder instead of ~/.codex. Codex reads ~/.codex/.env at startup, so a proxy line left there applies even when your shell has none.

How to read the results:

  • 405 from step 3 (or 401 if you send a POST) means this machine reaches the Codex endpoint over HTTPS; the endpoint only refuses the request because it carries no sign-in. That points away from DNS and basic routing.
  • Could not resolve host, Connection refused, a certificate error, or no answer means the problem is on the path from this machine.
  • Test-NetConnection succeeds but curl.exe -Iv fails with SEC_E_UNTRUSTED_ROOT means TCP works and Windows does not trust the certificate chain. That exact split was the cause in issue #41275 (August 28, 2026).
  • A proxy variable points to a port where step 4 finds nothing listening: Codex is sending traffic to a proxy that is not running.

With CLI 0.166.0 or later, Codex can run the WebSocket test itself with your sign-in:

bash
codex doctor --network-only

It checks the loaded config, the proxy environment, HTTP reachability of the active provider, and a Responses WebSocket handshake. A healthy WebSocket line reads connected (HTTP 101 Switching Protocols). A failure there, while step 3 returns 405, points at something that blocks or breaks WebSocket upgrades. Run it from the same environment as the failing client; a desktop app started from the Dock or Start menu does not read the variables in your shell profile.

What the curl check on the Codex endpoint points to: 405 means this machine reaches it over HTTPS, Could not resolve host or Connection refused means a problem on the path, SEC_E_UNTRUSTED_ROOT means Windows does not trust the certificate chain, and a proxy port with nothing listening means the proxy is not running

What the OS error in the message points to

When the final line is stream disconnected before completion: followed by an operating-system error, the error names the failing step:

Text in the messageWhat it points toReported example
Connection refused (os error 61) on macOS, os error 111 on Linux, os error 10061 on WindowsNothing was listening at the address Codex dialed: a proxy that is not running, or a leftover local endpointA stale HTTP_PROXY and HTTPS_PROXY in .codex\.env pointing at an unused port (#44517, September 10, 2026); openai_base_url = "http://127.0.0.1:11434/api/codex/v1" left over after Ollama stopped (forum, October 1, 2026); a stopped skill or MCP server (forum, October 23, 2026)
os error 10053 (An established connection was aborted by the software in your host machine)Software on the Windows machine closed the connection: a firewall, antivirus, VPN client, or local proxyCompare once with that software out of the path, if policy allows
Connection reset by peer (os error 54) on macOS, os error 104 on LinuxSomething between your machine and the server reset the connectionCompare a second approved network
websocket closed by server before response.completedThe WebSocket closed in the middle of a replyIf it repeats, check proxy idle-timeout and message-size limits for WebSockets
idle timeout waiting for websocket or idle timeout waiting for SSENo data arrived for 5 minutes, the default stream_idle_timeout_msLong silent turns or a middlebox that drops idle connections

All the reports linked above are user-reported causes for one machine each, not a list of how often each cause occurs.

Compare one network condition at a time

Keep the account, project, client version, and task size fixed. Change one approved condition:

  • compare the managed office path with an approved ordinary network;
  • temporarily compare VPN on versus off, if policy permits it;
  • confirm that a required local proxy process is listening on the port the Codex host receives;
  • when the failure occurs in WSL, a container, or Remote SSH, test from that host rather than from the laptop browser.

Record the time, the last visible state, and the exact error before and after the comparison. Recovery on a second network implicates the original route, but one successful attempt still does not distinguish DNS, TLS inspection, WebSocket handling, proxy rules, or another intermediary. OpenAI's network guidance uses the same test: does the error go away on a phone hotspot instead of the company Wi-Fi?

Do not confuse two network planes

Advice online often combines an .env file, HTTP_PROXY, and a WebSocket toggle into one universal answer. Codex has at least two relevant network planes:

  1. the client connection carrying model responses;
  2. outbound network access for commands Codex runs inside a sandbox.

OpenAI's permissions configuration spec defines the permission-profile network proxy for sandboxed command traffic. It can supply HTTP(S) and WebSocket proxy variables to tools. Changing that configuration can affect curl, a package manager, or another subprocess without proving that the Desktop app's own model stream takes the same route.

Retry and timeout keys copied from forum posts do not change the network path either; the next section shows which of them Codex accepts. Record the before-value of anything you change, change one setting at a time, and keep a rollback path. If you use a custom model provider, follow that provider's current transport documentation instead of applying a workaround written for ChatGPT sign-in.

stream_max_retries and other retry keys: what you can change

stream_max_retries, request_max_retries and stream_idle_timeout_ms exist, but only for a custom model provider. With ChatGPT sign-in, Codex uses the built-in openai provider, and its retry counts cannot be changed.

KeyDefaultWhat it controls
stream_max_retries5 (maximum 100)Retries of a dropped streaming reply: the 5 in Reconnecting... n/5
request_max_retries4 (maximum 100)Retries of a failed HTTP request to the provider
stream_idle_timeout_ms300000 (5 minutes)How long a stream may stay silent before Codex treats the connection as lost

The defaults come from the Codex configuration reference and match the source. The keys go in ~/.codex/config.toml, inside the [model_providers.<id>] table that defines your own provider:

toml
[model_providers.your-provider-id]
# keep the base_url, env_key and wire_api lines your provider already has
stream_max_retries = 10
request_max_retries = 4
stream_idle_timeout_ms = 300000

Built-in provider IDs (openai, ollama, lmstudio) are reserved. Putting these keys under [model_providers.openai] does not raise the limit. Codex refuses to load the configuration and stops with this error (codex-cli 0.166.0, as of November 16, 2026):

text
model_providers contains reserved built-in provider IDs: `openai`. Built-in providers cannot be overridden. Rename your custom provider (for example, `openai-custom`).

Two other settings come up in reconnect threads:

  • supports_websockets = false under [features] does nothing. supports_websockets is a per-provider field, not a feature flag, and codex features list has no such feature. For ChatGPT sign-in you cannot turn WebSockets off in config; Codex falls back to HTTPS by itself after the stream retries run out, and from 0.168.0 returns to WebSockets afterwards.
  • unbounded_connection_retries is the real switch behind waiting for network. It is a stable feature, on by default. Setting unbounded_connection_retries = false under [features], or starting Codex with --disable unbounded_connection_retries, makes connection failures use the bounded 5-retry path, so the turn fails instead of waiting. That suits scripts that should stop rather than hang. It does not fix the network.

One user in issue #13245 reported on July 21, 2026 that setting request_max_retries = 100, stream_max_retries = 100 and stream_idle_timeout_ms = 300000 on an Azure custom provider mostly stopped the disconnects. That applies to custom providers only.

After Reconnecting 5/5: restart the smallest scope

When the counter reaches 5/5, Codex either falls back from WebSockets to HTTPS and starts another round, or stops the turn with stream disconnected before completion. Once the turn has stopped, nothing more will retry on its own. Choose the smallest restart that matches the evidence:

  • One task fails: keep it. Start a new task with the goal, completed steps, file list, and remaining uncertainty. Ask the new task to inspect state before making changes.
  • One client fails: wait for other active tasks to finish, then fully quit the app or IDE host and reopen it. Closing a window may leave its background process alive.
  • All clients fail: check OpenAI Status, preserve the local timestamp, and make one approved network comparison. Do not repeatedly reinstall while the scope is still broad. On September 25, 2026, for example, 58 new issues quoting chatgpt.com/backend-api/codex/responses were opened on the Codex issue tracker in one day, against zero to two on the days around it. A wave like that points to the service, not to your network.
  • The reconnect succeeds: inspect git status and external systems before retrying. A tool or write may have completed even if its final UI message did not arrive.

The official troubleshooting guide specifically recommends waiting for active chats to complete before restarting the app. That condition protects other tasks that may still be writing files or running commands.

Session cleanup is a last resort

A single old task failing while new tasks in the same project work can justify investigating stored task state. It does not justify deleting every session.

OpenAI documents these locations:

  • macOS app logs: ~/Library/Logs/com.openai.codex/YYYY/MM/DD
  • active transcripts: $CODEX_HOME/sessions (normally ~/.codex/sessions)
  • archived transcripts: $CODEX_HOME/archived_sessions

Those files may contain prompts, paths, repository names, tool output, or other sensitive material. Review and redact before sharing. If you cannot identify the task-specific file confidently, use the /feedback flow from the affected task instead of deleting by timestamp.

If you eventually isolate a corrupt transcript, make a recoverable copy first and move only the exact file out of the active directory. Reopen Codex and test the same minimal request. A successful test shows that the isolated state mattered; it still does not prove every reconnect loop has the same fix.

What to include in a useful report

After version comparison, one network test, and a full restart, persistent failures deserve a focused report:

  • exact Codex client and version;
  • operating system and actual execution host;
  • local time and timezone;
  • the visible sequence from the first reconnect through the final error, copied exactly (for example Reconnecting... waiting for network and Connection failed: error sending request);
  • whether a new task and another Codex client work;
  • whether a basic terminal command works;
  • the result of one controlled network comparison;
  • the HTTP code from the curl check and the summary of codex doctor --network-only;
  • the smallest relevant, redacted log excerpt.

OpenAI's troubleshooting page explains how to send feedback with the current session and links to the public openai/codex issue tracker. Never include access tokens, cookies, email addresses, internal workspace names, private repository content, or an unreviewed data directory.

Identifying the affected task, client, or network is a diagnosis, not yet a repair. Confirm recovery by sending a small request in the environment that failed, checking its result, and resuming the task without repeated disconnects. If that still fails, use the narrowed diagnosis in your support report and keep the original task intact.

Found an error, or hit a problem this article does not cover? Send the article URL and what you saw to hi@laozhang.ai. We check it and update the article.