在运行aws configure
命令并从awscli
安装pip
库之后,我按照boto3 quickstart guide连接到我的AWS实例。但是,当我尝试连接时,出现以下错误:
OSError: Tunnel connection failed: 404 No such domain
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/botocore/vendored/requests/adapters.py", line 370, in send
timeout=timeout
File "/usr/local/lib/python3.6/site-packages/botocore/vendored/requests/packages/urllib3/connectionpool.py", line 597, in urlopen
_stacktrace=sys.exc_info()[2])
File "/usr/local/lib/python3.6/site-packages/botocore/vendored/requests/packages/urllib3/util/retry.py", line 271, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
botocore.vendored.requests.packages.urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='ec2.ca-central-1a.amazonaws.com', port=443): Max retries exceeded with url: / (Caused by ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 404 No such domain',)))
我认为这与错误的区域位置信息有关。
最佳答案
我发现问题出在地区标签上。即使AWS分别将区域名称列出为ca-central-1a
和ca-central-1b
,boto3仍仅查找ca-central-1
作为位置,否则问题中将出现上述错误。
进行了编辑,这要感谢@MarkB在ca-central-1a和-1b以下的注释,它们是ca-central-1地区中的可用区。学过的知识。
关于python - 使用python3中的boto3和示例代码访问Amazon EC2信息时出错,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/45774957/