Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/349.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Boto3中的异常-botocore.exceptions.EndpointConnectionError_Python_Amazon Web Services_Boto3 - Fatal编程技术网

Python Boto3中的异常-botocore.exceptions.EndpointConnectionError

Python Boto3中的异常-botocore.exceptions.EndpointConnectionError,python,amazon-web-services,boto3,Python,Amazon Web Services,Boto3,当尝试使用此python代码连接到数据库以测试连接时 import boto3 s3 = boto3.resource('s3') for b in s3.buckets.all(): print b.name 我正被这个错误抛向我 Traceback (most recent call last): File "boto3_test.py", line 4, in <module> for b in s3.buckets.all(): File "/usr

当尝试使用此python代码连接到数据库以测试连接时

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

for b in s3.buckets.all():
   print b.name
我正被这个错误抛向我

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/"
回溯(最近一次呼叫最后一次):
文件“boto3_test.py”,第4行,在
对于s3.bucket.all()中的b:
文件“/usr/local/lib/python2.7/dist packages/boto3/resources/collection.py”,第83行,在__
对于self.pages()中的页面:
文件“/usr/local/lib/python2.7/dist-packages/boto3/resources/collection.py”,第161行,共页
pages=[getattr(客户机、自身操作名称)(**参数)]
文件“/usr/local/lib/python2.7/dist packages/botocore/client.py”,第310行,在api调用中
返回self.\u make\u api\u调用(操作名称,kwargs)
文件“/usr/local/lib/python2.7/dist packages/botocore/client.py”,第385行,在make\u api\u调用中
操作(模式、请求)
文件“/usr/local/lib/python2.7/dist packages/botocore/endpoint.py”,第111行,在make_请求中
返回自我。发送请求(请求指令、操作模式)
文件“/usr/local/lib/python2.7/dist packages/botocore/endpoint.py”,第140行,在发送请求中
成功(响应,异常):
文件“/usr/local/lib/python2.7/dist packages/botocore/endpoint.py”,第213行,需要重试
捕获的\u异常=捕获的\u异常)
文件“/usr/local/lib/python2.7/dist packages/botocore/hooks.py”,第226行,在emit中
返回自发出(事件名称,kwargs)
文件“/usr/local/lib/python2.7/dist packages/botocore/hooks.py”,第209行,在
响应=处理程序(**kwargs)
文件“/usr/local/lib/python2.7/dist packages/botocore/retryhandler.py”,第183行,在调用中__
如果自我检查(尝试、响应、捕获异常):
文件“/usr/local/lib/python2.7/dist packages/botocore/retryhandler.py”,第250行,在调用中__
捕获(U异常)
文件“/usr/local/lib/python2.7/dist packages/botocore/retryhandler.py”,第273行,应重试
返回自我检查(尝试编号、响应、捕获异常)
文件“/usr/local/lib/python2.7/dist packages/botocore/retryhandler.py”,第313行,在调用中__
捕获(U异常)
文件“/usr/local/lib/python2.7/dist packages/botocore/retryhandler.py”,第222行,在调用中__
返回self.\u检查\u捕获的\u异常(尝试号,捕获的\u异常)
文件“/usr/local/lib/python2.7/dist packages/botocore/retryhandler.py”,第355行,在“检查”异常中
引发被捕获的异常
botocore.exceptions.EndpointConnectionError:无法连接到终结点URL:“https://s3.us-east-5.amazonaws.com/"

奇怪的是,连接在当天早些时候工作,然后在它停止工作,昨天同一时间发生在我身上的同样的事情,所以我假设这是一个网络配置问题。是唯一一个类似于原始海报所述解决方案的解决方案,该解决方案是取消设置HTTP_代理和HTTPS_代理,我尝试过,但没有成功

您未正确配置AWS env。检查您的
~/.aws/config
文件。您必须错误地将其配置为us-east-5,这是一个无效区域。将其更改为
us-east-1
。或者再次运行
aws configure
命令并指定正确的区域

[default]
region = us-east-1
我们突然发现了这个问题(返回状态代码500)

经过一些研究后,我们发现AWS上有一些infra更新,导致服务中断


您可以找到每个区域的当前关闭\up服务和即将到来的关闭时间

得到相同的boto3错误

在我的例子中,
config.lock
credentials.lock
是在幕后创建的:


删除它们解决了这个问题。

谢谢你,因为我认为区域是指时区而不是数据中心哈哈。@helloV在我的例子中,我在配置文件中正确配置了区域(ap-south-1),但仍然显示错误。还有什么原因?@helloV
botocore.exceptions.EndpointConnectionError:无法连接到终结点URL:“https://ec2.ap-south.amazonaws.com/“
这是错误消息。@helloV刚才在配置文件中将其更改为
ap south
,但仍然收到相同的错误。还有其他原因吗?@vishal.k很可能是Boto3从其他地方获得该地区。检查环境变量AWS\U DEFAULT\U region中是否配置了区域如果已设置,请取消设置并重试。见: