Codex CLI login stuck on 'Sign in with ChatGPT' screen
What version of Codex is running?
codex-cli 0.77.0
What subscription do you have?
Pro
Which model were you using?
_No response_
What platform is your computer?
Microsoft Windows NT 10.0.19045.0 x64
What issue are you seeing?
It looks like I ran into the same issue as https://github.com/openai/codex/issues/2763. I have 2+ VSCode windows (using devcontainers) open, and they both are mapping local ports to 1455:
<img width="1399" height="141" alt="Image" src="https://github.com/user-attachments/assets/05664d07-dc00-4e35-8b54-8879d24d2d25" />
<img width="1142" height="151" alt="Image" src="https://github.com/user-attachments/assets/00a3f002-2606-4787-b728-669f0cf1ffa1" />
While it says "User Forwarded", I don't recall making this forwards.
When I login via ChatGPT it hangs on this screen after hitting the continue button:
<img width="633" height="540" alt="Image" src="https://github.com/user-attachments/assets/e52649c3-00b0-4fad-a43f-09dd30f1a429" />
Based on this comment:
I closed one of the windows (the first picture), and now get:
<img width="530" height="487" alt="Image" src="https://github.com/user-attachments/assets/49afbf7c-3ce3-4e57-adef-c221e5b170f6" />
I rebuilt the devcontainer in the window that was still open, but that didn't fix it (same error as above):
<img width="1134" height="152" alt="Image" src="https://github.com/user-attachments/assets/62308a22-44a2-4bd5-a7b0-d74156cf802b" />
Next I reopened the project in VSCode and relaunched the devcontainer but got the same issue. I closed all vscode windows, and then reopened the project + relaunched the devcontainer but still have the same issue. Rebooting computer didn't seem to fix it. Deleting the forwarded port and re-adding it fixed it though.
What steps can reproduce the bug?
I haven't tried to reproduce it, but likely logging into codex with two different vscode windows + devcontainers might do it.
What is the expected behavior?
I would expect it to work or provide a better error message, if possible.
Additional information
_No response_
4 Comments
Please refer to this documentation for headless login.
Thanks! I suspect device code or copying auth cache would also work.
I think I observed this both with the codex CLI and VSCode extension (also running inside a devcontainer). If other people are running into this issue, should there be a better error message, or is that too hard to do here? Maybe the client could suggest it if it detects that it's likely running in a headless mode.
I just ran into this issue too, and I realized what the problem was. I had ChatGPT format it a bit:
Root Cause Analysis
This appears to be a port-forwarding conflict caused by Codex CLI’s fixed OAuth callback port combined with VS Code devcontainer behavior.
What’s happening:
1455.1455port forward.1455 → 1455on the host.1455, so VS Code remaps it (e.g.1455 → 1456) while still showing it as “User Forwarded”.localhost:1455, but no process is listening there — causing the login flow to hang indefinitely on the “Sign in with ChatGPT” screen.This explains why the issue only appears with multiple devcontainers and why it looks like auth succeeds but never completes.
---
Workaround / Fix
1455.1455correctly map to1455on the host.1455port forward again to avoid conflicts in other devcontainers.---
Suggested Improvement for Codex authors
Detect when you're operating in a devcontainer context, so that we can automatically close the forwarded port after authentication completes.
Thank you for posting this workaround. I just lost an hour of my life to this issue that I'll never get back.
Hope to see a fix for this soon.