Codex login failed? Troubleshoot sign-in
Identify whether login fails at the browser, local callback or token exchange. Keep the test in the affected client and environment.
Start here
Identify whether the browser, local callback or token exchange failed; use the callback port shown by your client.
Find the failing stage
A Codex login failure can happen before the browser opens, when the browser returns to the local client, or when the client exchanges authorization for credentials. Save the exact error and identify which client is failing: CLI, desktop app or IDE extension.
| What you see | Start here |
|---|---|
| Browser finishes, but the client still waits | Check where the callback listener runs. |
| Localhost connection is refused | Check whether the current login process is still listening at the displayed port. |
| Callback returns HTTP 500 | Read the client login error; the listener returned an error, so this alone does not establish a firewall block. |
| Token exchange failed | Inspect outbound authentication connectivity and the associated error. |
| Login status says signed in, but requests fail | Check the actual request error; stored login state is not proof that a credential is still usable. |
For the CLI, codex login status reports login state. It does not start a replacement authorization flow. If another login is already waiting for browser approval, finish or cancel that one before starting another.
Browser and callback failures
The official authentication guide describes localhost callbacks and recommends device-code authentication for supported headless environments. The default browser-login port is 1455; use the address printed by your installed client rather than assuming every build uses the same port.
With Remote-SSH, the CLI can run on a different machine from the browser. The same word, localhost, then refers to different machines. WSL can also involve forwarding and environment differences; it is not automatically broken simply because WSL is involved.
For a remote CLI that actually listens on port 1455, the documented SSH forwarding example is:
ssh -L 1455:localhost:1455 user@remote
Replace the user and host with your own remote account. Keep the tunnel open during login. If your client prints a different port, use the matching port or the supported device-code route. Do not expose the listener publicly or share a callback URL.
Use device-code login when appropriate
If available for your account or workspace, enable device-code login in ChatGPT security settings or through your workspace administrator, then run:
codex login --device-auth
Complete the instructions in the official browser flow. Do not send the one-time code to a helper or post it in a support ticket. If your account does not offer this method, use the supported alternatives in the authentication guide rather than repeatedly issuing the command.
Token exchange errors and HTTP 500
A callback returning HTTP 500 means a server answered but failed to handle the request successfully. It is different from a connection that never reaches a listener. A historical Linux report shows this together with a token-exchange failure; it does not establish a universal network cause.
Check the login-specific error and whether the client can reach its authentication service through the intended network. For an organization using TLS inspection, the official guide supports a corporate CA bundle through CODEX_CA_CERTIFICATE, with SSL_CERT_FILE as a fallback. Get the correct certificate from your administrator; do not disable TLS verification.
Current documentation places CLI login diagnostics in codex-login.log under the configured log directory. Do not paste the entire log publicly. Preserve the timestamp and relevant error while removing credentials and authorization URLs.
Invalidated or expired sessions
If the request explicitly reports an invalidated session, use the affected client’s normal sign-in flow. A desktop user report demonstrates why a stored signed-in state can coexist with an unusable credential. That report does not make every startup hang an authentication problem.
Do not delete the entire Codex directory, copy authentication files between environments as a routine repair, or switch to API-key billing just to make a login error disappear. API-key usage is a separate billing arrangement.
How to tell it worked
The login process finishes, the intended client reports the expected account, and a small request succeeds in the environment where the failure occurred. That request may consume usage. A successful browser page alone does not verify the client.
If it still fails, record the client version, OS, local/WSL/remote environment, exact error, callback port and timestamp. Public reports are supporting examples; this guide does not claim a reproduced universal fix or a fixed release.
This guide is part of our Codex login troubleshooting.
Compare another message in the Codex error guide library. First check whether this is a Codex service-side problem → View live Codex status.
Useful Codex tools
Sources
Each source lists what it is used to support. Sources are re-read on the review schedule, not continuously.
Browser and device-code authentication, remote forwarding, log location and corporate CA configuration.
Login status and supported login options.
Linux callback HTTP 500 report
Historical callback and token-exchange symptoms; no universal cause.
Reported mismatch between browser and listener hosts.
Desktop invalidated-session report
Stored login status can differ from actual request authentication.
Related guides
How this page is checked
- Evidence level
- Reported - based on public reports, not reproduced here
- Last reviewed
- 2026-09-22
- Content updated
- 2026-09-22
- Full version scope
- Current official authentication guidance with historical CLI/IDE callback reports and a Windows desktop invalidated-session report. Ports and UI vary by client; no universal fix version is claimed.
- Symptoms indexed
-
- You ran codex login or clicked sign-in, a browser step appeared to complete, but the client never reaches a signed-in state
- The browser never opens at all, or opens but lands on a page that will not load
- A token-exchange error appears in the terminal after the browser step
- You are stuck on the 'Sign in with ChatGPT' screen
Reviewer note
Source and editorial review on 2026-09-22. Official commands and documented behavior were checked against primary sources; public issue reports remain conditional evidence, not locally reproduced fixes.