Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exception in Boto3 - botocore.exceptions.EndpointConnectionError

When trying to connect to a database with this python code to test the connection.

import boto3
s3 = boto3.resource('s3')

for b in s3.buckets.all():
   print b.name

I am getting this error thrown at me.

Traceback (most recent call last):
  File "boto3_test.py", line 4, in <module>
    for b in s3.buckets.all():
  File "/usr/local/lib/python2.7/dist-packages/boto3/resources/collection.py", line 83, in __iter__
    for page in self.pages():
  File "/usr/local/lib/python2.7/dist-packages/boto3/resources/collection.py", line 161, in pages
    pages = [getattr(client, self._py_operation_name)(**params)]
  File "/usr/local/lib/python2.7/dist-packages/botocore/client.py", line 310, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/usr/local/lib/python2.7/dist-packages/botocore/client.py", line 385, in _make_api_call
    operation_model, request_dict)
  File "/usr/local/lib/python2.7/dist-packages/botocore/endpoint.py", line 111, in make_request
    return self._send_request(request_dict, operation_model)
  File "/usr/local/lib/python2.7/dist-packages/botocore/endpoint.py", line 140, in _send_request
    success_response, exception):
  File "/usr/local/lib/python2.7/dist-packages/botocore/endpoint.py", line 213, in _needs_retry
    caught_exception=caught_exception)
  File "/usr/local/lib/python2.7/dist-packages/botocore/hooks.py", line 226, in emit
    return self._emit(event_name, kwargs)
  File "/usr/local/lib/python2.7/dist-packages/botocore/hooks.py", line 209, in _emit
    response = handler(**kwargs)
  File "/usr/local/lib/python2.7/dist-packages/botocore/retryhandler.py", line 183, in __call__
    if self._checker(attempts, response, caught_exception):
  File "/usr/local/lib/python2.7/dist-packages/botocore/retryhandler.py", line 250, in __call__
    caught_exception)
  File "/usr/local/lib/python2.7/dist-packages/botocore/retryhandler.py", line 273, in _should_retry
    return self._checker(attempt_number, response, caught_exception)
  File "/usr/local/lib/python2.7/dist-packages/botocore/retryhandler.py", line 313, in __call__
    caught_exception)
  File "/usr/local/lib/python2.7/dist-packages/botocore/retryhandler.py", line 222, in __call__
    return self._check_caught_exception(attempt_number, caught_exception)
  File "/usr/local/lib/python2.7/dist-packages/botocore/retryhandler.py", line 355, in _check_caught_exception
    raise caught_exception
botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "https://s3.us-east-5.amazonaws.com/"

The strange part is that the connection was working earlier in the day and then at it stopped working the same thing happened to me yesterday at the same time so I am assuming it is a network configuration issue. This question is the only one that is similar the solution the original poster stated was to unset both HTTP_PROXY and HTTPS_PROXY which I attempted but it did not work.

like image 836
Liam Pieri Avatar asked Jan 08 '16 20:01

Liam Pieri


People also ask

What is botocore exceptions?

Botocore exceptions are statically defined in the botocore package. Any Boto3 clients you create will use these same statically defined exception classes. The most common botocore exception you'll encounter is ClientError .

What is Botocore?

Botocore is a low-level interface to a growing number of Amazon Web Services. Botocore serves as the foundation for the AWS-CLI command line utilities. It will also play an important role in the boto3. x project. The botocore package is compatible with Python versions Python 3.7 and higher.

What is a ClientError?

Client errors, or HTTP status codes from 400 to 499, are the result of HTTP requests sent by a user client (i.e. a web browser or other HTTP client).


1 Answers

You have configured AWS env incorrectly. Check your ~/.aws/config file. You must have configured it incorrectly as us-east-5 which is an invalid region. Change it to us-east-1. Or run aws configure command again and specify the correct region.

[default]
region = us-east-1
like image 182
helloV Avatar answered Sep 16 '22 22:09

helloV