Repository navigation
Description
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?
-
Open Codex Desktop on macOS (Apple Silicon).
-
Attempt to use Codex normally. Requests fail with:
"stream disconnected before completion: error sending request" -
Sign out of Codex and attempt to sign back in using the normal browser OAuth flow.
-
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)" -
Alternatively, install/run Codex CLI 0.147.0 and execute:
/opt/homebrew/bin/codex login --device-auth -
Device authentication immediately fails with:
"error sending request for url (https://auth.openai.com/api/accounts/deviceauth/usercode)" -
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 '{}' -
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
github-actions commentedon Aug 10, 2026
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
Formangarden524 commentedon Aug 29, 2026
I encountered a very similar issue on macOS Apple Silicon with Codex CLI 0.150.1.
Symptoms:
codex login --device-authfailed with:error sending request for url (https://auth.openai.com/api/accounts/deviceauth/usercode)curlcould reachauth.openai.comsuccessfully.The key breakthrough was enabling detailed Codex logging:
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:Nothing was listening on port 7890.
This explained why
curland 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:
I removed the stale proxy settings:
I also verified proxy-related environment variables, launchctl variables, Codex config, shell configuration, and
$CODEX_HOME/.env.After removing the stale proxy state, running:
immediately returned the normal device authorization flow and login succeeded.
The main lesson from this case is that the top-level Codex error:
can hide a failed local proxy hop.
For similar reports, I strongly recommend checking the effective proxy configuration early, especially:
And, most importantly, enable
RUST_LOG=traceto 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:7890proxy.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.