Omniscio

OmniscioGuidesAWS credentials expired or invalid

Claude Code: AWS credentials expired or invalid

Only the leading phrase, five words, is fixed. The middle of the message is your own configuration, so two people can see the same error with different commands in it.

Last checked against Anthropic's documentation on November 26, 2026. By the Omniscio team. Updated .

What is the message?

AWS credentials expired or invalid · run /login and select "Claude Platform on AWS · refresh credentials", or run `aws sso login --profile myprofile` in another terminal · API Error: 401 ...

Anthropic writes the middle of that line as an example. Its own entry says the action hint varies with your setup and that the stable part is the leading AWS credentials expired or invalid, so the command in yours is whatever awsAuthRefresh holds.

The trailing API Error: 401 ... is the API's own 401 line, which Anthropic shows at the end of the quote.

What does it mean?

Your AWS session token expired or was rejected. Anthropic says the message appears on a 401 from Claude Platform on AWS or from the Mantle endpoint on Amazon Bedrock, and that a 401 is how those providers report an expired security token. Anthropic describes Mantle as an Amazon Bedrock endpoint that serves Claude models through the native Anthropic API shape rather than the Bedrock Invoke API.

One version note matters if you are reading an old log: before v2.1.273 the message appeared only when awsAuthRefresh was configured, so a log from before that release will not show it for a managed environment.

How do I fix it?

  1. Read the hint before doing anything. If it says credentials are managed by this environment, the app that launched Claude Code owns the credential, and the rest of these steps do not apply: retry, or contact your administrator.
  2. With awsAuthRefresh set, run the command the message names in another terminal and finish the browser sign-in, then send your message again. Anthropic's example is aws sso login --profile myprofile, where SSO is AWS single sign-on.
  3. Without it, refresh whichever credential you use yourself: your SSO sign-in, access keys, API key, or proxy token.
  4. Or stay in the session: with awsAuthRefresh set, an interactive session can run /login → 3rd-party platform → Claude Platform on AWS · refresh credentials, which runs the same configured command and re-reads the credentials without a restart. Use this instead of step 2, not after it.
  5. If it repeats after a refresh that worked, run aws sts get-caller-identity in the same shell and profile. STS is AWS's Security Token Service, and that call prints the account and role the credentials actually resolve to. A valid identity outside Claude Code and a 401 inside it points at the profile Claude Code is using rather than at AWS.

How the two credential settings differ

Anthropic documents two settings, both set in your settings file, and which one you have changes when a refresh happens:

  • awsAuthRefresh runs only when Claude Code detects expired credentials, from their timestamp or from a credential error on a request, and then retries. Before running the command it makes an STS GetCallerIdentity call to confirm they really are expired, and skips the command when they still work. The command's output is shown to you, but it cannot take interactive input, which is why the browser-based SSO flow works and a prompt on stdin does not.
  • awsCredentialExport runs at session start and on each credential reload, even when the AWS default credential provider chain is still valid. Its output is captured silently and must be the JSON credential object Anthropic documents, with an optional ISO 8601 Expiration; with one, the credentials are cached until five minutes before it, and without one for an hour.

Anthropic also records a proxy note worth knowing on a locked-down network: the expiry check goes through your HTTPS_PROXY and NO_PROXY settings, and before v2.1.239 it went direct and could hang at startup on a network that only allows egress through a proxy.

The Bedrock and Vertex setup is the wider page for both settings: Claude Code on Bedrock and Vertex.

What does not help

  • Running /login and picking your Anthropic account. The credential at fault is the AWS one, and a claude.ai login does not replace it on a platform session.
  • Restarting Claude Code first. A restart re-reads the same expired credential; the refresh command is the step that changes it.
  • Assuming the profile in the hint is yours. The command comes from your settings, so an old AWS_PROFILE in a shell or in a settings env block is one reason the refresh succeeds against the wrong identity.

How do I know it is fixed?

  • The next request is answered instead of returning the 401.
  • aws sts get-caller-identity prints the account and role you expect, in the shell Claude Code was started from.
  • With awsAuthRefresh, a new session starts without running the refresh command at all, because Claude Code's expiry check finds the credentials valid.

Where these answers come from

Common questions

Is this an Anthropic error or an AWS one?

It is an AWS credential answer arriving through the API. Anthropic says the message appears on a 401 from Claude Platform on AWS or the Mantle endpoint, which is how those providers report an expired security token.

Why does my message name a command that is not in the docs?

Because the middle of the line is your own configuration. Anthropic says the action hint varies with your setup and only the leading AWS credentials expired or invalid is stable, so the command in the message is whatever awsAuthRefresh holds.

Do I have to restart Claude Code after refreshing?

Not with the in-session route. Anthropic documents running /login, choosing 3rd-party platform, then Claude Platform on AWS · refresh credentials, which runs the configured command and re-reads your AWS credentials without a restart. The other route is a command in another terminal, after which the next request picks the refreshed credential up.

The refresh command succeeded and the error came back. What then?

Confirm the identity outside Claude Code with aws sts get-caller-identity in the same shell and profile. That tells the refreshed token apart from a wrong profile, an expired role session, or a credential the launching environment owns.

Does awsAuthRefresh run on every start?

No. Anthropic says it runs only when Claude Code detects expired credentials, from their timestamp or from an API credential error, and before running it Claude Code makes an STS GetCallerIdentity call to confirm they really are expired.