How can I fix the error "Unable to locate credentials" when I try to connect to my Amazon S3 bucket using the AWS CLI?
Last updated: 2020-12-24
When I try to access my Amazon Simple Storage Service (Amazon S3) bucket using the AWS Command Line Interface (AWS CLI), I get an error. How do I fix this?
Resolution
An "Unable to locate credentials" error indicates that Amazon S3 can't find the credentials to authenticate AWS API calls. To resolve this issue, make sure that your AWS credentials are correctly configured in the AWS CLI.
Note: If you still receive an error when running an AWS CLI command, make sure that you’re using the most recent AWS CLI version.
To check if the AWS CLI is configured with credentials, run this command:
$ aws configure list
If your credentials are configured in the config file, the command returns a response similar to the following:
Name Value Type Location
---- ----- ---- --------
profile <not set> None None
access_key ****************ABCD config_file ~/.aws/config
secret_key ****************ABCD config_file ~/.aws/config
region us-west-2 env AWS_DEFAULT_REGION
If your credentials are configured in an instance profile, the command returns a response similar to the following:
Name Value Type Location
---- ----- ---- --------
profile <not set> None None
access_key ****************YVEQ iam-role
secret_key ****************2a9N iam-role
region <not set> None None
Review the response to check whether credentials are missing or the stored credentials are incorrect. If so, update your credentials.
Note: The AWS CLI invokes credential providers in a specific order, and the AWS CLI stops invoking providers when it finds a set of credentials to use. This means that if you have credentials configured incorrectly on a credential provider with higher precedence, then you get the "Unable to locate credentials" error. You get this error even if credentials are configured correctly on a provider with lower precedence.
After you update your credentials, test the AWS CLI by running an Amazon S3 AWS CLI command, such as aws s3 ls.
Related information
Did this article help?
Do you need billing or technical support?