The codex cli giving: 401 unauthorized

Open 💬 16 comments Opened Jan 13, 2026 by isha-paliwal3
💡 Likely answer: A maintainer (github-actions[bot], contributor) responded on this thread — see the highlighted reply below.

What version of Codex is running?

codex-cli 0.80.0

What subscription do you have?

chatgpt Plus

Which model were you using?

gpt-5.2 medium

What platform is your computer?

Windows

What issue are you seeing?

<img width="877" height="344" alt="Image" src="https://github.com/user-attachments/assets/09ced286-d6ff-4425-9aa1-47d4dcb124ac" />

<img width="849" height="406" alt="Image" src="https://github.com/user-attachments/assets/3b8b6209-415d-49bf-8f6d-45c395a57347" />

What steps can reproduce the bug?

Uploaded thread: 019bb81c-f4d0-7992

What is the expected behavior?

Should return a proper response

Additional information

_No response_

View original on GitHub ↗

16 Comments

github-actions[bot] contributor · 6 months ago

Potential duplicates detected. Please review them and close your issue if it is a duplicate.

  • #8807
  • #8703
  • #7918
  • #7362
  • #7107

Powered by Codex Action

etraut-openai contributor · 6 months ago

It looks like you've logged out and logged back in. Is that correct? You could try deleting the auth.json file manually and then log in again, but that's unlikely to fix it.

What type of ChatGPT plan do you have? Is it a Plus subscription?

isha-paliwal3 · 6 months ago
It looks like you've logged out and logged back in. Is that correct? You could try deleting the auth.json file manually and then log in again, but that's unlikely to fix it. What type of ChatGPT plan do you have? Is it a Plus subscription?

Hi @etraut-openai, yes I have a plus subscription, And I tried deleting the auth.json as well but it did not fix it

etraut-openai contributor · 6 months ago

This must be something specific to your account. Could I get your user ID? You can find it by going to https://chatgpt.com/codex, clicking on the upper right icon to show the profile menu and then clicking on your email address (top menu item). This will put your user ID on the clipboard so you can paste it here. It will be of the form "user-<string of random characters>".

alphaai · 6 months ago

I am also experiecing the same problem. user-JpFWYFj65MQ76y39JSuMrua9

isha-paliwal3 · 6 months ago

@etraut-openai here is my user Id can you pls check?

user-SiimSO1vjX7pcbW1JqTimawk

peterjliu · 6 months ago

also having same issue.

  1. on Teams plan with SAML setup to Google Workspace
  2. Can log-in and use chatGPT
  3. get 401 after logging into codex
etraut-openai contributor · 6 months ago

By any chance, are all of you who are experiencing the 401 error using the "log in with Google" option? Are any of you using an OpenAI account password to log in?

peterjliu · 6 months ago

Yes using Google to log-in or passkey. Over the past few months I observed multiple issues with SSO and chatGPT (e.g. https://github.com/openai/codex/issues/3782#issuecomment-3311165906, https://github.com/openai/codex/issues/5553). I think you should take a look at this seriously.

voxmenthe · 6 months ago

I have this same issue. On pro plan. Using OpenAI account password to log in.
Originally had collision with port 1455 but killed that port and it allowed me to log in.
But still got 401 error after that.
Also tried deleting auth.json and re-logging in. Still 401 error.
Oddly, this authentication issue does not affect the codex app/extension in VSCode/Cursor etc.

etraut-openai contributor · 6 months ago

@voxmenthe, if you're able to repro the problem, please use the /feedback slash command to upload your logs and post the thread ID here. Are you using any firewalls, VPNs, proxies or other special network configurations?

voxmenthe · 6 months ago
@voxmenthe, if you're able to repro the problem, please use the /feedback slash command to upload your logs and post the thread ID here. Are you using any firewalls, VPNs, proxies or other special network configurations?

I am able to repro it - did the feedback thread ID 019bde1b-34a7-7c72-90da-c4cfdd31a024
Additional context is that the issue seems limited to a particular repo.

etraut-openai contributor · 6 months ago

@voxmenthe, thanks for uploading your logs. It looks like you're using the endpoint https://api.z.ai/api/coding/paas/v4/responses. Given the symptom you're seeing (an error that's specific to a particular repo), I'm guessing that the error is coming from this endpoint rather than OpenAI. Are you able to repro the problem if you use the standard OpenAI endpoint?

voxmenthe · 6 months ago

Yeah thanks I had just figured that out. unset OPENAI_BASE_URL and works

peterjliu · 5 months ago

hi @etraut-openai can you look into my repro, thread id 019be460-d2b8-7b13-b17a-2a3334ea74d6

joelcma · 5 months ago
Yeah thanks I had just figured that out. unset OPENAI_BASE_URL and works

Yes! That worked for me too! Perhaps a tool like this should use a more obscure env var name so people don't accidentally override it?