[BUG] AWS token expires frequently in Claude Code
Environment
- Platform (select one):
- [ ] Anthropic API
- [x] AWS Bedrock
- [ ] Google Vertex AI
- [ ] Other: <!-- specify -->
- Claude CLI version: 0.2.76 (Claude Code)
- Operating System: MacOS 15.3.2 (24D81)
- Terminal: iTerm 2
Bug Description
Claude frequently fails with "API Error: The SSO session associated with this profile has expired. To refresh this SSO session run aws sso login with the corresponding profile."
Running aws sso login indeed fixes the issue for a while, but the issue comes back in an hour or two - much sooner than what's our standard AWS token expiry time (4h - and with autorefresh, it can last for more than 12h as that's Okta session lifetime).
Meanwhile, other aws commands (or coding assistants using bedrock; aws CLI or boto3 based) keep working fine on the same box while Claude is erroring out. It seems like Claude is doing something non-standard - how are you interfacing with AWS?
<img width="1219" alt="Image" src="https://github.com/user-attachments/assets/e570907b-9765-46a3-a10d-f45442492a11" />
10 Comments
(By the way, sometimes using a boto3 tool refreshes the Claude Code's token as well, w/o calling aws sso login. But that's not happening reliably.)
Could you try the latest (0.2.86) and let us know if this still repros?
@bcherny confirmed this is still an issue in v0.2.86.
After about hour in my Claude session I received the following error (note: permission set has a 12 hour duration):
In another tab I was able to successfully run
aws sts get-caller-identityusing the same AWS profile as Claude was using.I was then able to prompt Claude to "continue" and it was able to successfully continue interacting with Bedrock.
I'm not able to confirm, but I feel like in previous versions once I hit an API error claude was dead and I needed to kill it and start a new session.
I'm wondering it is now configured to successfully refresh creds on API failure so they're available for the next prompt, but lacks the ability to refetch credentials and resume the current task without user input.
@fitz-vivodyne thanks for letting us know! We've shipped 0.2.89 today with another potential fix, could you give it a try with
claude update?@levpopov I was able to continue using an existing Claude session beyond the 1 hour mark which is definitely an improvement (Claude 0.2.90)
Claude was not actively completing a task at the one hour mark at the moment I'm assuming the credentials would have expired, so I'm unsure if that scenario is still an issue.
Will provide details if I encounter further issues.
Thanks!
@pasky could you try with the latest version and let us know if this is feeling better for you?
Hi, sorry, I switched to Windsurf for now, won't be able to test it short term. If it works for fitz, I'd assume it's fixed!
I've been using Claude consistently for the past couple days without further issues.
I think it's safe to close this issue, can always re-open/create a new one if it pops up again.
This has been a great quality of life improvement, thanks!
thanks for confirming, @fitz-vivodyne !
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.