Frequent re-authentication required
Resolved 💬 11 comments Opened Jan 23, 2026 by Fergonz1993 Closed Apr 6, 2026
💡 Likely answer: A maintainer (etraut-openai, contributor)
responded on this thread — see the highlighted reply below.
Problem
As a Pro subscriber paying $200/month, I am constantly required to re-authenticate with codex login - sometimes multiple times per day. This severely disrupts workflow and is unacceptable for a paid tier.
## Environment
- Codex CLI version: 0.89.0
- OS: macOS
- Auth method: ChatGPT Pro
Symptoms:
- Running
codex execor other commands results in repeated 401 Unauthorized errors - Error messages: "Missing bearer or basic authentication in header"
- Error messages: "failed to refresh available models: unexpected status 401 Unauthorized"
- After re-authenticating, the session works briefly, then fails again
Expected Behavior: Pro tier authentication should persist for a reasonable duration (days/weeks), not require constant re-login.
Impact:
- Breaks automated workflows
- Interrupts development flow constantly
- Makes the tool unreliable for serious use
- Paying premium price for a degraded experience
Please fix the token refresh mechanism so Pro subscribers don't need to constantly re-authenticate.
11 Comments
Thanks for reporting the problem.
Does this only occur with non-interactive mode, or do you see it with the interactive CLI as well? If it occurs in the CLI, please use the
/feedbackcommand the next time it happens. Upload your logs and post the thread ID below. This will allow us to dig into the cause in more detail.When it fails, does it start working again if you just relaunch the CLI and resume where you left off? Or does it continue to fail with a 401 once it's in that mode?
Does it ask you to re-auth when you restart, or do you need to explicitly
/logoutand log back in?BTW, it's unlikely that this is related in any way to your subscription plan type.
Mostly on the CLI.
Next time I will use the feedback command. I guess I would upload my logs
and post the thread ID below the feedback command.
When it fails, it prompts me to log in again, and I do so, and it continues
working. Then, it prompts me to log in again because it's looking for the
API key or something.
So, yeah, it's not me; I do have restarted it a couple of times already,
but I'm just sending you the feedback. Already did the logo thing, the
restart thing. There's no 401 though. It's just like it prompts itself to
log in because it's trying to look for the API key or something.
I'm not an expert on this. You are.
Thank you for the fast response though.
On Fri, Jan 23, 2026 at 5:18 PM Eric Traut @.***> wrote:
--
Fernando L. González H.
The symptoms you're describing are very odd.
A few more follow-up questions:
config.tomlfile that might be relevant to this issue?I encountered this error message when using the API.
@gaoconggit, please use the
/feedbackcommand to upload your logs and session details, then post the thread ID here.I'm in the CI environment.
I encountered this problem right after upgrading from 0.87.0 to 0.92.0.
@gaoconggit, I think it's unlikely that you're experiencing the same underlying issue as the one reported by the OP, but I can't tell for sure without additional details. The OP is reporting a situation where Codex works for a while but then starts to receive 401 errors. Is that what you're seeing, or are you seeing a 401 immediately? A 401 typically indicates that your API key is invalid or has been revoked for some reason. You could try creating a new API key.
--config features.remote_models=false
---
It solved my problem.
Additional reproduction data: REST fallback drops auth header after websocket failure
Environment: Codex CLI 0.117.0, Linux x64, ChatGPT Pro OAuth (
auth_mode: chatgpt)Root cause identified: When the websocket endpoint (
wss://api.openai.com/v1/responses) returns 500 Internal Server Error and exhausts all retry attempts, Codex falls back to the REST endpoint (https://api.openai.com/v1/responses). However, the REST fallback request is sent without the Authorization header, resulting in 401 "Missing bearer or basic authentication in header."Reproduction steps:
wss://api.openai.com/v1/responsesis returning 500 (server-side issue)codex exec --dangerously-bypass-approvals-and-sandbox "Print hello"Log output:
Key observations:
codex login statuscorrectly shows "Logged in using ChatGPT"OPENAI_API_KEYenv var is also set but REST fallback doesnt use it eitherImpact: Any automated pipeline (CI, agent loops, scheduled tasks) silently fails when websocket has transient issues. The combination of (1) dropped auth header and (2) exit code 0 means failures go undetected.
Suggested fix: Ensure the REST/HTTP fallback path in
codex_api::endpointpropagates the same Authorization header (Bearer token or API key) that the websocket path uses.@joeykrug, your analysis wouldn't explain what the OP was seeing. Websocket support wasn't added to the source base until about a month after this bug was filed. If you're seeing an issue involving websockets, please open a new issue. Use
/feedbackto upload your logs and session details and include the thread ID in the bug report. Thanks!It sounds like the OP's issue was resolved, so I'm going to close this issue.