Moto mock_s3 EndpointConnectionError, Соединение отклонено - PullRequest
0 голосов
/ 15 апреля 2020

Я пытаюсь смоделировать мое соединение S3 с moto

@mock_s3
def setUp(self):
   self.s3_client = S3Client()
   self.s3_client.create_bucket(BUCKET_NAME)

Но я получаю следующие ошибки:

botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL:"http://localhost:4567"

or

ConnecConnection refused

1 Ответ

0 голосов
/ 15 апреля 2020

Проблема заключалась в том, что я указал конечную точку в вызове ресурса:

self.s3_resource = boto3.resource(
    "s3",
    endpoint_url=endpoint,
    use_ssl=use_ssl,
    region_name=region,
)

Удаление endpoint_url или просто установка его в None решает проблему:

self.s3_resource = boto3.resource(
    "s3",
    endpoint_url=None,
    use_ssl=use_ssl,
    region_name=region,
)
...