Codexauth

Codex Sign-in Fails With token_exchange_failed

Codex says token exchange failed: error sending request for auth.openai.com/oauth/token. The usual causes and what to try, step by step.

3 min read Updated Applies to Codex

What is going on

You sign in to Codex in the terminal, the editor extension or the desktop app. The browser says you are signed in, and then Codex shows token exchange failed: error sending request for url (https://auth.openai.com/oauth/token).

The browser step worked. What failed is the next one: Codex itself could not reach OpenAI's sign-in server to finish the login. That points to something between your computer and the internet, not to your account.

Error messages you might see

token exchange failed: error sending request for url (https://auth.openai.com/oauth/token)
error code token_exchange_failed
Sign-in could not be completed
Return to Codex to retry, switch accounts, or contact your workspace admin if access is restricted

Common causes

  1. A VPN, proxy or company network that lets your browser through but blocks or changes the request Codex makes. Proxy settings added in one terminal window are often not seen by the desktop app or the editor extension.
  2. A DNS filter or local DNS helper (some VPN and security tools use one) that the Codex program does not resolve names through.
  3. Windows with WSL: the editor extension started Codex inside WSL, or another program is holding the local port used for sign-in. One reported case was wslrelay.exe holding port 1455.
  4. A company proxy that replaces the website's security certificate, which Codex does not trust.
  5. Damaged sign-in data left over from an earlier attempt.

How to fix it

These steps come from reports by other users. They are not an official guarantee, and the cause differs from one setup to another.

  1. From the same computer, run curl -I https://auth.openai.com/.well-known/openid-configuration. A normal response means the machine can reach the server. If this works but Codex still fails, suspect proxy settings, DNS or WSL.
  2. Turn off any VPN, DNS filter or security proxy for a minute and try again.
  3. If you use a proxy, set HTTPS_PROXY and NO_PROXY for your whole user account, not only one terminal. Include localhost,127.0.0.1 in NO_PROXY. Then quit Codex completely and start it again.
  4. On Windows with WSL, sign in from a normal terminal instead of the editor extension, or turn off the extension's WSL option, then try again.
  5. Sign out and in again: codex logout, then codex login, then codex login status to check.
  6. Try codex login --device-auth, which signs you in with a code on another device. It can fail for the same network reasons.

If none of this works, a developer can look at your network and proxy settings with you on a call.

Getting help takes about a minute

No hiring, no back and forth. A real person looks at your app.

  1. 1

    Describe it

    Tell us what you need in plain words. You don't have to be technical or have an account to start.

  2. 2

    Free 15-minute call

    A verified developer calls you. Many tasks are sorted right there, and it costs nothing.

  3. 3

    Pay after you approve

    If there is more to do, you get one fixed price up front. You pay only once you are happy.

Get help

Real people, reviewed by hand

Developers who do this every day

Every developer is approved by our team before they can take a task. Describe yours and the first one who is free picks it up.

Get help

Questions

Does this mean my OpenAI account is blocked?

Usually not. The error means Codex could not reach the sign-in server from your computer. Account access is a likely cause only if a workspace admin has restricted it, which the message mentions separately.

Why does the browser say I am signed in but Codex does not?

The browser finishes its part, then Codex has to make its own request to complete the login. A proxy, VPN or DNS setting can block that second request while the browser works fine.

Keep reading

Can't fix it yourself?
Real developers can help.

Get help