Skip to content

macOS: Codex auth requests fail with "error sending request" while curl to the same endpoint returns HTTP 200 #37863

Closed

Description

@kwis7

What version of the Codex App are you using (From “About Codex” dialog)?

Version 26.803.41515

What subscription do you have?

ChatGPT Pro

What platform is your computer?

macOS, Apple Silicon (arm64)

What issue are you seeing?

Codex Desktop and CLI were previously working normally on this Mac, but suddenly started failing with:

"stream disconnected before completion: error sending request"

I signed out while troubleshooting, and since then I have been unable to sign back in.

Normal OAuth login fails during token exchange with:

"Token exchange failed: error sending request for url (https://auth.openai.com/oauth/token)"

Device authentication also fails:

"Error logging in with device code: error sending request for url (https://auth.openai.com/api/accounts/deviceauth/usercode)"

Web ChatGPT and Web Codex work normally.

I have tested multiple networks (Wi-Fi and mobile hotspot), removed VPN/Clash, verified that system proxies are disabled, and tested both the bundled Codex CLI and standalone stable Codex CLI 0.147.0.

Most importantly, curl can successfully POST to the exact same device-auth endpoint from the same Mac. Both IPv4 and IPv6 return HTTP 200 with a valid device_auth_id and user_code. TLS and certificate verification also succeed.

Therefore, the OpenAI authentication endpoint is reachable from this machine, but Codex itself reports "error sending request" when accessing the same endpoint.

The issue appeared suddenly after Codex had previously been working normally.

What steps can reproduce the bug?

  1. Open Codex Desktop on macOS (Apple Silicon).

  2. Attempt to use Codex normally. Requests fail with:
    "stream disconnected before completion: error sending request"

  3. Sign out of Codex and attempt to sign back in using the normal browser OAuth flow.

  4. Complete authentication in the browser. The final token exchange fails with:
    "Token exchange failed: error sending request for url (https://auth.openai.com/oauth/token)"

  5. Alternatively, install/run Codex CLI 0.147.0 and execute:
    /opt/homebrew/bin/codex login --device-auth

  6. Device authentication immediately fails with:
    "error sending request for url (https://auth.openai.com/api/accounts/deviceauth/usercode)"

  7. From the same Mac and network, POST to that exact endpoint using curl:
    curl -4 -X POST https://auth.openai.com/api/accounts/deviceauth/usercode -H 'Content-Type: application/json' -d '{}'

  8. The curl request succeeds with HTTP 200 and returns a valid device code. Repeating the test with curl -6 also succeeds with HTTP 200.

The issue is consistently reproducible across both Wi-Fi and a mobile hotspot. Web ChatGPT and Web Codex continue to work normally.

What is the expected behavior?

Codex Desktop and CLI should be able to connect to OpenAI normally and complete requests without "stream disconnected" or "error sending request" errors.

After signing in through the browser, Codex should successfully exchange the authorization code for a token and complete the login.

Similarly, codex login --device-auth should successfully contact the device-auth endpoint, return a device code, and allow authentication to complete.

Since the same OpenAI authentication endpoints are reachable from this Mac via curl, Codex should also be able to communicate with them successfully.

Additional information

No response

Activity

  1. added
    app
    on Aug 10, 2026
  2. added
    bug
    CLI
    auth
    connectivity
    on Aug 10, 2026
  3. github-actions commented on Aug 10, 2026

    @github-actions
    Contributor

    Potential duplicates detected. Please review them and close your issue if it is a duplicate.

    Powered by Codex Action

  4. Formangarden524 commented on Aug 29, 2026

    @Formangarden524

    I encountered a very similar issue on macOS Apple Silicon with Codex CLI 0.150.1.

    Symptoms:

    • codex login --device-auth failed with:
      error sending request for url (https://auth.openai.com/api/accounts/deviceauth/usercode)
    • Browser access worked.
    • curl could reach auth.openai.com successfully.
    • DNS, IPv4/IPv6, TLS, and the OpenAI auth endpoint itself were all reachable.

    The key breakthrough was enabling detailed Codex logging:

    RUST_LOG=trace \
    RUST_BACKTRACE=full \
    codex login --device-auth

    The log revealed that Codex was not connecting directly to auth.openai.com. It was trying to tunnel the HTTPS request through an old local proxy:

    proxy(http://127.0.0.1:7890/) intercepts 'https://auth.openai.com/'
    connecting to 127.0.0.1:7890
    connect error for 127.0.0.1:7890:
    Connection refused (os error 61)
    

    Nothing was listening on port 7890.

    This explained why curl and the browser could work while Codex consistently failed.

    During troubleshooting I also found stale global Git proxy configuration:

    git config --global --get-regexp '.*proxy.*'

    returned:

    http.proxy http://127.0.0.1:7890
    https.proxy http://127.0.0.1:7890
    

    I removed the stale proxy settings:

    git config --global --unset http.proxy
    git config --global --unset https.proxy

    I also verified proxy-related environment variables, launchctl variables, Codex config, shell configuration, and $CODEX_HOME/.env.

    After removing the stale proxy state, running:

    codex login --device-auth

    immediately returned the normal device authorization flow and login succeeded.

    The main lesson from this case is that the top-level Codex error:

    error sending request for url (...)
    

    can hide a failed local proxy hop.

    For similar reports, I strongly recommend checking the effective proxy configuration early, especially:

    env | grep -i proxy
    
    for v in HTTP_PROXY HTTPS_PROXY ALL_PROXY http_proxy https_proxy all_proxy; do
      launchctl getenv "$v"
    done
    
    cat ~/.codex/.env
    
    git config --global --get-regexp '.*proxy.*'
    
    lsof -nP -iTCP:7890 -sTCP:LISTEN

    And, most importantly, enable RUST_LOG=trace to see the actual connection target.

    In my case, hours of DNS, TUN, Fake-IP, IPv4/IPv6, TLS and VPN troubleshooting were ultimately unnecessary. The decisive evidence was the hidden attempt to connect to a dead 127.0.0.1:7890 proxy.

    It would be very helpful if Codex surfaced the effective proxy target in the user-facing error message, e.g. local proxy 127.0.0.1:7890 connection refused, instead of only showing the final OpenAI URL.

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

    CLIappauthbugconnectivity

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions