Skip to content

Reconnecting 5/5 hides actual connection failure and endpoint, causing misleading network troubleshooting #53222

Open

Description

@mesh-newbie

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?

  1. Install Codex CLI 0.162.1 on macOS.

  2. Authenticate using a ChatGPT account:

    codex login

  3. Add the following configuration to ~/.codex/config.toml:

    openai_base_url = "http://127.0.0.1:11434/api/codex/v1"

  4. Ensure no service is listening on localhost port 11434.

  5. Execute:

    codex exec "Reply with exactly: Connection test successful"

  6. Observe repeated reconnection messages:

    Reconnecting... waiting for network
    Reconnecting 2/5
    Reconnecting 3/5
    Reconnecting 4/5
    Reconnecting 5/5

  7. Inspect diagnostic output to discover the actual failure:

    Connection refused (os error 61)
    ws://127.0.0.1:11434/api/codex/v1/responses

  8. 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:

  1. Display the destination hostname and port during reconnection failures.

  2. Distinguish between:

    • Connection refused
    • Connection timeout
    • DNS resolution failure
    • TLS/certificate failure
    • Authentication failure
    • Server-side errors
  3. Identify when a custom endpoint override is active.

  4. Provide a collapsible "Connection details" section containing the underlying error and endpoint.

  5. For localhost connection failures, suggest checking the local service and configuration.

  6. 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

  1. added
    bug
    on Oct 11, 2026
  2. added
    CLI
    connectivity
    on Oct 11, 2026
  3. KonradAppel commented on Oct 19, 2026

    @KonradAppel

    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 status showed Logged in using ChatGPT) and internet access worked via an iPhone hotspot.

    My ~/.codex/config.toml contained:

    openai_base_url = "http://127.0.0.1:11434/api/codex/v1"

    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_url points to an unavailable localhost service, especially when a hosted GPT model is selected, rather than reporting a generic network problem.

  4. MahendraRao commented on Oct 24, 2026

    @MahendraRao

    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:

    • Existing conversations repeatedly displayed Reconnecting... waiting for network.
    • A brand-new conversation with Reply with exactly: OK also failed.
    • The application reached Reconnecting 5/5 and remained in the Thinking state for over a minute.
    • Regular ChatGPT conversations worked normally in Google Chrome.

    Root cause investigation:

    I inspected ~/.codex/config.toml and found the following configuration:

    openai_base_url = "http://127.0.0.1:11434/api/codex/v1"

    Workaround applied:

    1. Created a backup of config.toml.
    2. Commented out the openai_base_url override.
    3. Restarted Codex Desktop.
    4. Opened a new conversation and repeated the exact same prompt.

    Result: SUCCESS

    Codex immediately returned:

    OK
    

    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.

    Image Image

    Thank you for investigating this issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    CLIbugconnectivity

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions