Prabhat
Prabhat

Reputation: 4426

AWS S3 CLI - Could not connect to the endpoint URL

$ aws s3 ls

Could not connect to the endpoint URL: "https://s3.us-east-1a.amazonaws.com/"

What could be the problem?

Upvotes: 191

Views: 327757

Answers (22)

Dev pokhariya
Dev pokhariya

Reputation: 336

I faced same issue. The problem was I was using us-east1 as my default region while it should be us-east-1

run

aws configure

then fix this

Default region name [us-east1]: us-east-1

Happy Terraforming !!

Upvotes: 0

Francisco C
Francisco C

Reputation: 381

I ran into this error in trying to set up a connection to AWS from within WSL. Turned out I simply was not connected to the internet when working in WSL. So make sure that is not the problem (use ping google.com, for example).

If internet is the issue, I found this thread to be very helpful. In particular, changing the ~/etc/resolv.conf file resolved my issue.

Upvotes: 2

Muthukumar M
Muthukumar M

Reputation: 1

Check VM security group rules and add outbound rule for S3 access .

Upvotes: 0

Ali UÇAR
Ali UÇAR

Reputation: 1

If you are sure that you did everything correctly, If you are using a Company PC, disconnect VPN connection.

This worked for me.

Upvotes: 0

Yasin Türk
Yasin Türk

Reputation: 11

If you are using ec2 just:

export AWS_DEFAULT_REGION=your-region

Upvotes: 0

Under4Mhz
Under4Mhz

Reputation: 73

Check your environment settings:

set |& grep REGION

I had a typo in my AWS_REGION and AWS_DEFAULT_REGION environment variables, so it was trying to access a non-existant region.

Upvotes: 1

Zhenya
Zhenya

Reputation: 6198

Weirdly, in my case restarting my laptop has helped. I've been using VPN lately, I think it messed up some network settings causing this error.

Upvotes: 3

Jadhav Gaurav
Jadhav Gaurav

Reputation: 578

This worked for me.

  1. Use debug option to get clear idea of bug

aws ec2 describe-instances --instance-ids (myid) --region ap-south-1 --debug

I got following issue.

EndpointConnectionError: Could not connect to the endpoint URL: "https://ec2.ap-south-1b.amazonaws.com/"

  1. I tried to Ping but it was not working

ping ec2.ap-south-1b.amazonaws.com ping: ec2.ap-south-1b.amazonaws.com: Name or service not known

  1. I checked for invalid value for Region when using aws configure

but it was configured properly

[default] region = ap-south-1

  1. Then , I went to **IAM -> Users - > (yourusername) - > Add Permissions

and I added "AdministratorAccess" Policy**.

  1. After that everything worked for me.

MainThread - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): ec2.ap-south-1.amazonaws.com:443 MainThread - urllib3.connectionpool - DEBUG - https://ec2.ap-south-1.amazonaws.com:443 "POST / HTTP/1.1" 200 7176

Upvotes: 3

Shrikant Gawande
Shrikant Gawande

Reputation: 21

In case it is not working in your default region, try providing a region close to you. This worked for me:

   PS C:\Users\shrig> aws  configure
   AWS Access Key ID [****************C]:**strong text**
   AWS Secret Access Key [****************WD]:
   Default region name [us-east1]: ap-south-1
   Default output format [text]:

Upvotes: 2

Mintu
Mintu

Reputation: 512

  1. Check the .aws directory under home directory. Windows: C:\Users<home-name>.aws Linux: ~/.aws

  2. Under this directory, you will find the config as well as credentials file. It will have the information from the aws configure that you may have run before. IF not, then

  3. Run aws configure Enter the access key - secret key - enter secret key region - (ap-southeast-1 or us-east-1 or any other regions) format - (json or leave it blank, it will pick up default values you may simply hit enter)

  4. From the Step 2, you should see the config file, open it, it should have the region. Please ensure there is region specified.

  5. You may now run the following command to list the buckets aws s3 ls It should work fine.

Upvotes: 1

techjunkie
techjunkie

Reputation: 211

On Windows run the aws configure command again and reset region without the letter for example if your region is us-east-1a you need to change it to us-east-1 in order for it to work.

enter image description here

Upvotes: 0

Nicole Douglas
Nicole Douglas

Reputation: 649

The solution to my problem was to run:

    sudo aws configure

Enter your credentials and then run:

    sudo aws s3 ls

A different solution was to make sure that the region in the .aws/config file is the same as the endpoints

Upvotes: 0

dave vedant
dave vedant

Reputation: 699

Everyone has different defaults, and interestingly it will change after time. As an example, first I was on global, and then after 15 minutes it shows Ohio (which is us-east-2).

The best approach is to check it during your work -- in console of your AWS working area, just set it on the right above side near your name on top bar check your region name and click on the down arrow to see your region.

In AWS CLI type aws configure or aws2 configure, give your access and secret id, then during default region, write your region and press Enter.

You will definitely get access to specific region set and it will work.

Upvotes: 0

adam ali
adam ali

Reputation: 21

You should do the following on the CLI : 1. aws configure'
2. input the access key 3. input secret key 4. and then the region i.e : eu-west-1 (leave the a or b after the 1)

Upvotes: 2

Vladyslav Didenko
Vladyslav Didenko

Reputation: 1631

Couple things I've done to fix this :

  1. Updated my CLI and it given this error (previous error was "aws connection aborted error 10013")
  2. Tried to nslookup aws s3 endpoing : nslookup s3.us-east-2.amazonaws.com

    DNS request timed out. timeout was 2 seconds. Server: UnKnown Address: 192.168.10.1

-> hmmm very weird

  1. Went to windows network troubleshooting and selected to test access to specific page. It informed that Windows firewall blocked the connection. Fixed this

  2. Received a new error , after fixing the request through firewal :

    An error occurred (RequestTimeTooSkewed) when calling the ListBuckets operation: The difference between the request time and the current time is too large.

  3. Updated my date & time to automatic -> Fixed

Upvotes: 0

canadadry
canadadry

Reputation: 8443

Assuming that your profile in ~/aws/config is using the region (instead of AZ as per your original question); the other cause is your client's inability to connect to s3.us-east-1.amazonaws.com. In my case, I was unable to resolve that DNS name due to an error in my network configuration. Fixing the DNS issue solved my problem.

Upvotes: 1

Sonal
Sonal

Reputation: 679

Probably, there is something wrong with the default region while configuring aws. In your case, the URL says "https://s3.us-east-1a.amazonaws.com/"

In your command prompt,

aws configure, enter your keys, Now fix your region from us-east-1a to us-east-1.

Kindly check the syntax according to the CLI you are using. This will be helpful.

Upvotes: 6

Luke
Luke

Reputation: 61

You should specify the region in your CLI script, rather than rely on default region specified using aws configure (as the current most popular answer asserts). Another answer alluded to that, but the syntax is wrong if you're using CLI via AWS Tools for Powershell.

This example forces region to us-west-2 (Northern California), PowerShell syntax:

aws s3 ls --region us-west-2

Upvotes: 6

imTheManager
imTheManager

Reputation: 389

If none of solutions given above works,also check your permissions and firewall settings. In my case adding proxy environment variables did the job.

For Linux or mac

$ export HTTP_PROXY=http://<YOUR PROXY IP>:<PORT>

$ export HTTPS_PROXY=http://<YOUR PROXY IP>:<PORT>

For Windows

set HTTP_PROXY=http://<YOUR PROXY IP>:<PORT>

set HTTPS_PROXY=http://<YOUR PROXY IP>:<PORT> aws cli Windows

enter image description here

Upvotes: 15

Thomas Thiemann
Thomas Thiemann

Reputation: 161

Some AWS services are just available in specific regions that do not match your actual region. If this is the case you can override the standard setting by adding the region to your actual cli command.

This might be a handy solution for people that do not want to change their default region in the config file. IF your general config file is not set: Please check the suggestions above.

In this example the region is forced to eu-west-1 (e.g. Ireland):

aws s3 ls --region=eu-west-1

Tested and used with aws workmail to delete users:

aws workmail delete-user --region=eu-west-1 --organization-id [org-id] --user-id [user-id]

I derived the idea from this thread and it works perfect for me - so I wanted to share it. Hope it helps!

Upvotes: 9

fraya
fraya

Reputation: 111

first you use 'aws configure' then input the access key, and secret key, and the region. the region you input would be important for this problem. try to input something like 's3.us-east-1', not 's3.us-east-1a'. it will solve the issue.

Upvotes: 11

Frederic Henri
Frederic Henri

Reputation: 53703

You probably have something wrong in your default profile for the default region.

Check your file at ~/.aws/config, you have something like

[default]
region=us-east-1a
...

Fix the region to region=us-east-1 and then the command will work correctly

Upvotes: 392

Related Questions