codex icon indicating copy to clipboard operation
codex copied to clipboard

use account with ChatGPT plus subscription to login Codex CLI get 401 Unauthorized

Open botingw opened this issue 1 year ago • 17 comments

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

botingw avatar Aug 31 '25 23:08 botingw

Getting this with a ChatGPT Pro account today too.

Manouchehri avatar Sep 01 '25 16:09 Manouchehri

me too awful

pandac55 avatar Sep 02 '25 09:09 pandac55

I also have this on Pro:

  • 2 projects in the same subnet work
  • 2 projects in other subnets don't and get the error from OP

It was working fine a few days ago

MantraMedia avatar Sep 04 '25 14:09 MantraMedia

same error. cannot use it since days ago. Please fix this issue.

TudorCB avatar Sep 08 '25 15:09 TudorCB

Same error ! exceeded retry limit, last status: 401 Unauthorized

ascot31 avatar Sep 09 '25 22:09 ascot31

Same error ! exceeded retry limit, last status: 401 Unauthorized

I tried logging out and then logging back in, and that worked for me.

ascot31 avatar Sep 09 '25 22:09 ascot31

Same issue here with ChatGPT Enterprise.

hamed-cta avatar Sep 12 '25 03:09 hamed-cta

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.

fengqiangzhao avatar Sep 12 '25 06:09 fengqiangzhao

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.

makaixindalao avatar Sep 15 '25 01:09 makaixindalao

Same using ChatGPT account. Infuriating.

Image

HillPhelmuth avatar Sep 16 '25 18:09 HillPhelmuth

Solution that worked for me: https://github.com/openai/codex/issues/1243#issuecomment-3290984360

rr- avatar Sep 16 '25 20:09 rr-

Solution that worked for me: #1243 (comment)

how to fix it?

lnnujxxy avatar Sep 17 '25 02:09 lnnujxxy

Solution that worked for me: #1243 (comment)

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

makaixindalao avatar Sep 17 '25 02:09 makaixindalao

Solution that worked for me: #1243 (comment)

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

passingby000 avatar Sep 18 '25 08:09 passingby000

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.

etraut-openai avatar Nov 21 '25 06:11 etraut-openai

still having this 401 issue. OPENAI_API_KEY environment variable is needed for other apps and i must keep it.

faketrader avatar Jan 16 '26 02:01 faketrader

@FakeTrader, if you're seeing a behavior you believe to be a bug, please use the /feedback slash command to open a new issue.

etraut-openai avatar Jan 16 '26 03:01 etraut-openai