Reputation: 565
I am trying to mock my S3 connection with moto
@mock_s3
def setUp(self):
self.s3_client = S3Client()
self.s3_client.create_bucket(BUCKET_NAME)
But i get the following errors:
botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL:"http://localhost:4567"
or
ConnecConnection refused
Upvotes: 3
Views: 2576
Reputation: 565
The problem was that i specified an endpoint in the resource call:
self.s3_resource = boto3.resource(
"s3",
endpoint_url=endpoint,
use_ssl=use_ssl,
region_name=region,
)
Removing endpoint_url or just setting it to None solves the problem:
self.s3_resource = boto3.resource(
"s3",
endpoint_url=None,
use_ssl=use_ssl,
region_name=region,
)
Upvotes: 4