Linux: Token exchange failed: error sending request for url (https://auth.openai.com/oauth/token)
What version of Codex is running?
codex-cli 0.46.0
What subscription do you have?
PLUS
Which model were you using?
gpt-5-codex
What platform is your computer?
Linux 6.17.1-arch1-1 x86_64 unknown (Arch linux)
What issue are you seeing?
GET
http://localhost:1455/auth/callback?code=redacted&scope=openid profile email offline_access&state=redacted
Status
500
Internal Server Error
VersionHTTP/1.1
Transferred252 B (90 B size)
Referrer Policystrict-origin-when-cross-origin
Request PriorityHighest
DNS ResolutionSystem
What steps can reproduce the bug?
When I started using codex cli, it worked fine for like 2 hours max, then I'd get errors from openapi responses.
The solution for this was to delete "rm -rf ~/.codex" and relogin with the cli.
But now this also does not work. I am not able to log in at all anymore.
I always get the token exchange error no matter what (different linux machines, browsers, terminals etc.) I try.
What is the expected behavior?
Redirect to the CLI with proper auth tokens, not throw 500 error.
Additional information
I tried with
Kitty terminal, Zen browser
Chromium
VSCodium
Ghostty
Disabled UFW
Checked internet connectivity.
Setting DNS to 8.8.8.8
Ensuring no VPN or other IP link is active(besides Ethernet cable)
Nothing works.
15 Comments
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
I figured out what's causing the issue.
If I enable/disable wireguard client, I need to reboot my system before I can use the cli again.
Not sure why this is the case as I'm able to ping the domain
I had the same issue on WSL. What worked for me was opening the console, installing Codex globally, running it once, logging in, and then restarting Windows in VS Code — after that, everything started working fine.
To fix the Token exchange failed error, you must launch VS Code with explicit proxy settings and a crucial bypass list, ensuring external OpenAI traffic goes through the proxy while local authentication callbacks remain direct.
Fixed by changing the SOCKS proxy to an HTTP proxy.
Issue still exists
The error is on Codex/Openai side
I came here with the same problem.
For reference:
uname -s -o -r -m: Linux 6.14.0-35-generic x86_64 GNU/LinuxI tried
rm -rf ~/.codex,ufw allow 1455/tcp, downgrading the node to 18, and reinstalling modules certifi and requests in Python,but the Codex (login) does not work.
<img width="307" height="299" alt="Image" src="https://github.com/user-attachments/assets/24b43471-c438-4289-ba2d-625fc6f1ce79" />
I have resolved the issue.
In Codex, when I press the Enter key on the screen above, it is registered twice.
If the screen above appears again, please press the Enter key once more.
When the screen switches to the one below, try logging in at that moment.
It seems that only at this point the web browser correctly receives the login information.
<img width="540" height="287" alt="Image" src="https://github.com/user-attachments/assets/93e8057d-9651-4274-984c-7e4e8fbdb251" />
I'm chinese,I have the same issue.I'm ubuntu22.04,please help me.
我遇到同样的问题了,有兄弟解决了吗
one the reasons in Windows was enabling WSL mode
there is no response from openai
Closing old bug.
If you're having problems with our normal interactive auth flow for some reason (e.g. a local firewall or other network settings), you can try using the headless device authentication techniques.
In the file
C:\Users\{User}\.codex\config.tomlMake sure this is set:
windows_wsl_setup_acknowledged = falseif it's
truethen login will not works.I added
localhost,::1and127.0.0.1to the "Http: No Proxy" setting, but the problem still occurs. Disabling the proxy didn't help either. Could you please tell me which addresses you added? @zhao926777In the devtools i see the error:
A networking error occurred during POST request to
https://ab.chatgpt.com/v1/rgstr?k=client-REDACTED&st=javascript-client-react&sv=3.27.0&t=REDACTED&sid=REDACTED&ec=REDACTEDInvalid URL protocol: the URL must start withhttp:orhttps:.use socks proxy can solve the problem
Token exchange failed: error sending request for url (https://auth.openai.com/oauth/token)still facing this issue.