AWS: Unable to locate credentials / Could not load credentials from any providers
The AWS CLI/SDK found no credentials in any place it looks — env vars, profile files, SSO cache or an instance/task role.
Meaning
The SDK’s credential chain checks environment variables, ~/.aws/credentials + config profiles, SSO, web identity, then ECS task role and EC2 instance metadata. None produced credentials.
Common causes
- No
aws configure/ SSO login on this machine - AWS_PROFILE set to a profile that doesn’t exist
- Running as another user (sudo, cron, systemd) with a different HOME
- EC2 instance without an IAM role, or IMDSv2 hop limit too low in containers
- CI job missing OIDC role assumption
⚡ Quick fix
aws sts get-caller-identityto testaws configureoraws sso login --profile x- Attach an IAM role to the EC2 instance / ECS task / Lambda
- For containers on EC2 with IMDSv2, raise the hop limit to 2
Detailed fix by platform
AWS
- Debug the credential chain:bash
aws sts get-caller-identity --debug 2>&1 | grep -i -E 'credential|profile' | head env | grep ^AWS_ aws configure list
How to diagnose
- Where — Laptop, CI, EC2, container, Lambda?
- Chain — Which providers did the SDK try?
- User — Which OS user/HOME runs the process?
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 2 Oct 2026