Fix for vscode/cursor plugin: stream error: exceeded retry limit, last status: 401 Unauthorized

Since gpt-5-codex release, I started seeing stream error: exceeded retry limit, last status: 401 Unauthorized in vscode/cursor. Here’s how I fixed:

  1. Shut down vscode/cursor
  2. mv ~/.codex/auth.json ~/.codex/auth.json.bak
  3. Start vscode/cursor back up, and log back in (Select login with ChatGPT, not with API).

Quite an easy fix, but took me a while to figure it out. Leaving here to help the next person!

23 Likes

I had this exact same problem suddenly after the gpt-5-codex release and doing this solved my problem

2 Likes

Welcome to the community, @moogman .

We appreciate you taking the time to share this with others.

Hope you stick around. We’ve got a great community here!

Happy coding…

1 Like

I had the same issue and it fixed it for me as well.

1 Like

Switching to login with ChatGPT probably works, but how to fix the “use API key“ scenario?

I am using Windows, and I want to use an OpenAI API Key. I tried the key with read-only, restricted and all permissions, i put the key in the env var as well as in config.toml, and also entered it when starting codex extension for the first time. Unfortunately, no luck. Still get stream error: exceeded retry limit, last status: 401 Unauthorized; retrying

It started to work! It looks like it requires All permission on API key. And if you change it recently you need to wait about 5 minutes. Looks like having the key in auth.json (codex adds it there when asks you to login to ChatGPT or use API key) is enough you don’t need to add it to env variables or in config.toml

Bro, I created an account just to thank you hahaha. Worked like a charm :partying_face:

1 Like

I’ve been trying to fix this for a few days. That worked, thanks a lot!

hello, for some reasons, I have to use API Key, and it will have the issue “exceeded retry limit, last status: 401 Unauthorized”, can anyone solve the problem?

did people find what’s wrong with this when using codex SDK?