Skip to content

/errors/aws-cli/unable-to-locate-credentials

AWS CLI: Unable to locate credentials. You can configure credentials by running aws configure

The commands on this page have not been executed by our verification runner yet.updated 2026-10-20
tool
AWS CLI
exit code
253
versions
AWS CLI v2
os
any

The AWS CLI looks for credentials in a fixed order: command-line options, environment variables, the shared credentials and config files (including SSO and credential_process profiles), and finally container and instance roles. When every step comes up empty, it stops with Unable to locate credentials. You can configure credentials by running "aws configure".

See what the CLI found

bash
aws configure list            # shows each value and where it came from (env, shared-credentials-file, iam-role…)
aws configure list-profiles
aws sts get-caller-identity   # succeeds only with working credentials

Fix: local machine

bash
aws configure sso             # IAM Identity Center (recommended)
aws sso login --profile dev
export AWS_PROFILE=dev

aws configure with access keys also works, but keys stored in ~/.aws/credentials never expire, so prefer SSO.

Fix: CI and servers

  • GitHub Actions, GitLab CI: let the job assume an IAM role through OIDC (for example the aws-actions/configure-aws-credentials action) instead of storing keys as secrets.
  • EC2 / ECS / EKS: attach an instance profile, task role or IRSA / Pod Identity role; the CLI picks it up automatically.
  • sudo or another user: ~ changes, so ~/.aws is not found; run without sudo or pass AWS_CONFIG_FILE and AWS_SHARED_CREDENTIALS_FILE.

Sources