Repository navigation
Description
What version of the Codex App are you using (From “About Codex” dialog)?
Codex 0.147.0
What subscription do you have?
ChatGPT Plus account
What platform is your computer?
No response
What issue are you seeing?
Codex 0.147.0: token_exchange_failed after successful browser authentication on Windows and WSL
Environment
- Windows 11 x64
- ChatGPT Plus account
- Codex CLI:
codex-cli 0.147.0 - Codex installed via npm on Windows
- Tested with Codex Desktop as well as Codex CLI
- Additionally tested with a fresh Codex installation inside WSL/Linux
Problem
Codex authentication cannot be completed.
The browser authentication itself succeeds. After signing in, the browser confirms that authentication was successful and says that the page can be closed.
However, Codex subsequently fails when exchanging the authorization code for a token:
Sign-in could not be completed
Token exchange failed: error sending request for url
(https://auth.openai.com/oauth/token)
Error code: token_exchange_failed
Details:
Token exchange failed: error sending request for url
(https://auth.openai.com/oauth/token)
This occurs both with Codex Desktop and the Codex CLI.
Device authentication also fails
I also tested:
codex login --device-auth
This fails with:
Error logging in with device code:
error sending request for url
(https://auth.openai.com/api/accounts/deviceauth/usercode)
Network tests
DNS resolution works:
nslookup auth.openai.com
Name: auth.openai.com.cdn.cloudflare.net
Addresses:
2a06:98c1:310c::ac40:920f
2606:4700:4400::6812:29f
104.18.41.241
172.64.146.15
Aliases: auth.openai.com
HTTPS connectivity to the authentication server also exists:
curl -I https://auth.openai.com
returns:
HTTP/1.1 403 Forbidden
Cf-Mitigated: challenge
Server: cloudflare
So the machine can reach auth.openai.com, but Cloudflare responds with a challenge to the curl request.
Proxy tests
Windows WinHTTP configuration:
netsh winhttp show proxy
DirectAccess (no proxy server)
No proxy environment variables are present:
set | findstr /I "proxy"
returns no output.
Different network tested
To rule out the router, ISP connection, or public IP address, I disconnected the PC from the normal network and connected it through a mobile phone hotspot.
The Codex authentication failure remained exactly the same.
Therefore, the problem does not appear to be specific to the normal internet connection, router, or public IP.
WSL/Linux test
To rule out a problem specific to the native Windows Codex runtime, I installed WSL and a Linux environment.
Node.js/npm and Codex were installed natively inside WSL.
The Linux Codex installation was verified:
which codex
/usr/local/bin/codex
codex --version
codex-cli 0.147.0
I then ran:
codex login
The browser opened and authentication completed successfully. The browser explicitly indicated that the login was successful and that the page could now be closed.
After closing the browser page, however, Codex did not complete the login successfully.
The token exchange failed again.
Thus, the problem can be reproduced with:
- Codex Desktop on Windows
- Codex CLI on Windows
- Codex CLI running natively inside WSL/Linux
- normal internet connection
- separate mobile hotspot
Additional symptom
Before investigating the authentication problem, Codex had also repeatedly produced connection errors similar to:
stream disconnected before completion:
error sending request for url
(https://chatgpt.com/backend-api/codex/responses)
It is unclear whether this is related, but it may indicate a more general connectivity problem between the Codex client and OpenAI endpoints.
At approximately the same time, the normal ChatGPT browser session unexpectedly required a new login. The ChatGPT browser login itself succeeded.
Summary
Browser authentication works, but Codex cannot complete the subsequent communication with OpenAI's authentication endpoints.
The issue persists after ruling out:
- DNS resolution
- normal internet connection
- router
- public IP (tested via mobile hotspot)
- WinHTTP proxy
- proxy environment variables
- native Windows Codex runtime
- alternative device authentication
- Codex running inside WSL/Linux
The most notable observation is that the browser reports a successful Codex authentication, but the subsequent token exchange performed by Codex fails.
Please advise whether this could be related to the current Codex authentication/token exchange implementation, Cloudflare handling, or an account/session-side issue.
What steps can reproduce the bug?
I cant use codex or Chatgpt localy
What is the expected behavior?
It works until this afternoon - suddenly the connection was frozen
Additional information
No response
Activity
github-actions commentedon Aug 7, 2026
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
HansKohlhaas commentedon Aug 7, 2026
Related to #36490 — same token-exchange failure; additional evidence: WSL + hotspot + Cloudflare challenge.
yxy050208 commentedon Sep 21, 2026
I recently reproduced the same Windows-side pattern: browser authentication completed successfully, but Codex failed during the final OAuth token exchange because the browser/system route and the route actually used by Codex were different.
I turned the diagnostics from that investigation into a small open-source Windows utility: DevNet Doctor
https://github.com/yxy050208/DevNetDoctor
It compares WinINET/Windows system proxy, WinHTTP, process/user proxy environment variables, local proxy listener state, and direct vs system-proxy vs env-proxy reachability to the OpenAI OAuth endpoint. It also checks Codex
respect_system_proxywithout reading token contents.v0.1.0 release:
https://github.com/yxy050208/DevNetDoctor/releases/tag/v0.1.0
Disclosure: I'm the maintainer. This is diagnostic-first and does not assume every
token_exchange_failedhas the same cause. For this issue, the useful output is the redacted Findings + Route matrix, which can show whether Windows/WSL/Codex are actually taking different network paths.kushkatech commentedon Sep 22, 2026
I can reproduce a very similar issue on the current Windows Codex Desktop build.
Important: started immediately after an update
This issue started immediately after Codex Desktop updated to
26.915.4065.0.Before that update, Codex Desktop was working normally on the same machine, with the same ChatGPT account, VPN configuration, WSL2 environment, and projects.
After the update, Codex started experiencing repeated connectivity problems, eventually logged me out, and I have not been able to sign in again since then.
Environment
26.915.4065.0Error
After completing the browser login, Codex Desktop fails with:
Sign-in failed: Login server error: Token exchange failed: error sending request for url (https://auth.openai.com/oauth/token)Network tests
The token endpoint itself is reachable from both Windows and WSL.
From Windows, IPv4 through the VPN:
curl.exe -4 -v -d "grant_type=test" https://auth.openai.com/oauth/tokensuccessfully establishes TLS and returns:
HTTP/1.1 400 Bad Requestwith the expected OpenAI response saying that
testis not a supportedgrant_type.The same POST over IPv6 also succeeds and returns the expected HTTP 400 response.
From WSL:
curl -4 -v -d "grant_type=test" https://auth.openai.com/oauth/tokenalso successfully completes DNS, TLS 1.3 and HTTP/2, and OpenAI returns:
HTTP/2 400with the expected invalid
grant_typeJSON response.So TCP connectivity, DNS, TLS certificate verification, Cloudflare access, and POST access to
/oauth/tokenall work from both Windows and the WSL environment.Test-NetConnection auth.openai.com -Port 443also succeeds.Rollback tests
I also tested older Windows Desktop packages:
26.908.4834.026.911.7940.0Both older versions can launch, but I encounter persistent
Reconnecting...behavior when trying to use the chat, so rollback has not provided a usable workaround.The application also attempted to automatically update back to
26.915.4065.0after rollback.Additional observations
The Desktop logs repeatedly contain WSL git watcher errors such as:
EISDIR: illegal operation on a directory, watch '\\wsl$\OracleLinux_9_5\...'but I have not found the actual OAuth
token_exchange_failederror in the Electron desktop log.Given that:
26.915.4065.0,/oauth/tokenis reachable from both Windows and WSL,kushkatech commentedon Sep 23, 2026
The sign-in issue (Token exchange failed) persists in Windows Codex Desktop 26.917.8451.0.