use account with ChatGPT plus subscription to login Codex CLI get 401 Unauthorized
What version of Codex is running?
codex-cli 0.27.0
Which model were you using?
gpt-5
What platform is your computer?
Darwin 24.4.0 x86_64 i386
What steps can reproduce the bug?
npm install -g @openai/codex
codex
(in codex): select login, then browser pop up ChatGPT login page, after click to login, terminal into " To get started, describe a task or try one of these commands: ......"
/model > select Minimal
/status > "📂 Workspace
• Path: {my-repo-path}
• Approval Mode: on-request
• Sandbox: workspace-write
• AGENTS files: (none)
👤 Account
• Signed in with ChatGPT
• Login: {my-chatgpt-account-(google-email)}
• Plan: Plus
🧠 Model
• Name: gpt-5
• Provider: OpenAI
• Reasoning Effort: Minimal
• Reasoning Summaries: Auto
📊 Token Usage
• Session ID: 856285e8-9cc8-486c-9bd2-1ce0e95b5b42
• Input: 0
• Output: 0
• Total: 0"
type "hello, summarize what do README.md say"
"hello, summarize what do README.md say
⚠ stream error: exceeded retry limit, last status: 401 Unauthorized; retrying 1/5 in 214ms…
⚠ stream error: exceeded retry limit, last status: 401 Unauthorized; retrying 2/5 in 430ms…
⚠ stream error: exceeded retry limit, last status: 401 Unauthorized; retrying 3/5 in 789ms…
⚠ stream error: exceeded retry limit, last status: 401 Unauthorized; retrying 4/5 in 1.532s…
⚠ stream error: exceeded retry limit, last status: 401 Unauthorized; retrying 5/5 in 3.336s…
🖐 exceeded retry limit, last status: 401 Unauthorized"
What is the expected behavior?
ChatGPT plus subscription should not out of quota even first time with minimal reasoning effort (I assume 401 is caused by out of quota or system cannot get my credential).
What do you see instead?
as in reproduce bug, retry 5 times and fail
Additional information
_No response_
17 Comments
Getting this with a ChatGPT Pro account today too.
me too awful
I also have this on Pro:
It was working fine a few days ago
same error. cannot use it since days ago. Please fix this issue.
Same error ! exceeded retry limit, last status: 401 Unauthorized
I tried logging out and then logging back in, and that worked for me.
Same issue here with ChatGPT Enterprise.
Same issue here with ChatGPT Plus.
I also tried to run /logout, but it didn’t work. The only way I got it working was after clearing the environment variables OPENAI_BASE_URL and OPENAI_API_KEY.
This is very confusing because I chose to sign in with my account (ChatGPT Plus) instead of using an API key.
When I use Codex in WSL2, I can log in successfully but I keep getting 401 errors when using it. It works normally in Windows.
Same using ChatGPT account. Infuriating.
<img width="397" height="122" alt="Image" src="https://github.com/user-attachments/assets/ae6cc764-03cd-47c3-8969-1e12db3702d4" />
Solution that worked for me: https://github.com/openai/codex/issues/1243#issuecomment-3290984360
how to fix it?
I deleted the OPENAI_BASE_URL and OPENAI_API_KEY in environment variables, then rebooted the system and finally got back to normal
worked for me. Thank you hugely
I think this issue is no longer valid, so I'm closing. If you see similar issues with the latest version of the CLI, please open a new bug report.
still having this 401 issue. OPENAI_API_KEY environment variable is needed for other apps and i must keep it.
@FakeTrader, if you're seeing a behavior you believe to be a bug, please use the
/feedbackslash command to open a new issue.