Repository navigation
Description
What issue are you seeing?
Codex displays misleading "Reconnecting... waiting for network" messages when the actual failure is a connection refusal from a configured custom endpoint.
This occurred in both the macOS desktop application and Codex CLI 0.162.1.
The user-facing messages were:
Reconnecting... waiting for network
Reconnecting 5/5
Connection failed: error sending request
The requests repeatedly failed, requiring sessions to be abandoned and restarted.
After investigating network connectivity, authentication, Cloudflare and OpenAI service availability, I discovered that Codex was attempting to connect to a local endpoint configured in ~/.codex/config.toml:
openai_base_url = "http://127.0.0.1:11434/api/codex/v1"
The actual diagnostic error was:
ERROR codex_api::endpoint::responses_websocket:
failed to connect to websocket:
IO error: Connection refused (os error 61)
url: ws://127.0.0.1:11434/api/codex/v1/responses
Codex knew the destination and the precise failure, but the user interface only reported a generic network reconnection problem.
Removing the configuration override immediately restored functionality in both Codex CLI and the desktop application.
The underlying connection refusal was legitimate. The bug being reported is the failure to expose actionable diagnostic information to the user.
What steps can reproduce the bug?
-
Install Codex CLI 0.162.1 on macOS.
-
Authenticate using a ChatGPT account:
codex login
-
Add the following configuration to ~/.codex/config.toml:
openai_base_url = "http://127.0.0.1:11434/api/codex/v1"
-
Ensure no service is listening on localhost port 11434.
-
Execute:
codex exec "Reply with exactly: Connection test successful"
-
Observe repeated reconnection messages:
Reconnecting... waiting for network
Reconnecting 2/5
Reconnecting 3/5
Reconnecting 4/5
Reconnecting 5/5 -
Inspect diagnostic output to discover the actual failure:
Connection refused (os error 61)
ws://127.0.0.1:11434/api/codex/v1/responses -
Remove the openai_base_url override and repeat the test.
Result: Codex immediately connects successfully and returns:
Connection test successful
The same configuration change also restored normal operation in the macOS desktop application.
The issue is reproducible without an actual internet connection failure.
What is the expected behavior?
Codex should expose the actual connection failure rather than displaying only a generic "waiting for network" message.
For example:
Connection failed
Endpoint: 127.0.0.1:11434
Error: Connection refused (os error 61)
Configuration: ~/.codex/config.toml
The configured endpoint is not accepting connections.
Check that the local service is running, or remove the custom openai_base_url override to use the default OpenAI endpoint.
Suggested improvements:
-
Display the destination hostname and port during reconnection failures.
-
Distinguish between:
- Connection refused
- Connection timeout
- DNS resolution failure
- TLS/certificate failure
- Authentication failure
- Server-side errors
-
Identify when a custom endpoint override is active.
-
Provide a collapsible "Connection details" section containing the underlying error and endpoint.
-
For localhost connection failures, suggest checking the local service and configuration.
-
Preserve the underlying error after reconnection attempts are exhausted.
The interface should not imply that internet connectivity is the problem when the actual failure is a refused connection to localhost.
Additional information
Environment:
- macOS, Apple Silicon
- Codex CLI 0.162.1
- Authentication: ChatGPT account
- Model: GPT-6
- Provider: OpenAI
- Reasoning effort: Medium
The problem was experienced on two separate Macs using different internet connections.
The investigation initially suggested an OpenAI service outage or network instability because of the generic reconnection messages.
Basic HTTPS connectivity to api.openai.com was working normally (HTTP 401 without credentials, as expected).
The decisive diagnostic information was only discovered after running Codex CLI and examining its error output.
Following removal of the localhost endpoint override:
- Codex CLI immediately completed a test request.
- The macOS desktop application also completed a request without reconnecting.
This demonstrates that the underlying problem was straightforward to identify once the actual endpoint and connection error were visible.
The current reconnection messages obscure information that Codex already possesses, making a simple configuration problem unnecessarily difficult to diagnose.
This is especially disruptive during long-running tasks, where repeated connection failures can result in abandoned sessions and lost productivity.
A "Show connection details" option would significantly improve troubleshooting without adding complexity to the normal user experience.
Activity
KonradAppel commentedon Oct 19, 2026
Confirming this fix on macOS (Codex desktop app and CLI). Both were stuck on
Reconnecting... waiting for network, even though ChatGPT login was valid (codex login statusshowedLogged in using ChatGPT) and internet access worked via an iPhone hotspot.My
~/.codex/config.tomlcontained:Ollama was not running. The surprising part was that I had selected a GPT model, not an Ollama model, but Codex still tried to use the configured local endpoint. Resolving the Ollama connection/endpoint configuration fixed the issue.
Suggestion: show a warning when a custom
openai_base_urlpoints to an unavailable localhost service, especially when a hosted GPT model is selected, rather than reporting a generic network problem.MahendraRao commentedon Oct 24, 2026
Confirmed additional reproduction and successful workaround — macOS Codex Desktop
I encountered the same issue on October 24, 2026, using Codex Desktop on macOS.
Initial behavior:
Reconnecting... waiting for network.Reply with exactly: OKalso failed.Reconnecting 5/5and remained in the Thinking state for over a minute.Root cause investigation:
I inspected
~/.codex/config.tomland found the following configuration:Workaround applied:
config.toml.openai_base_urloverride.Result: SUCCESS
Codex immediately returned:
The repeated reconnection problem disappeared.
This strongly supports the original report that a stale custom endpoint can cause misleading network reconnection errors.
Suggested product improvement:
Codex Desktop should detect when a custom endpoint override is configured and display the actual endpoint and connection error, rather than repeatedly reporting a generic network failure.
A diagnostic message identifying the relevant configuration file and unreachable endpoint would have significantly reduced troubleshooting time.
I have before-and-after screenshots demonstrating the failure and successful recovery.
Thank you for investigating this issue!