question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

urllib3.exceptions.ReadTimeoutError: AWSHTTPConnectionPool when connecting to moto server

See original GitHub issue

(1) I am running a standalone moto_server on a localhost on port 5000 with:

  • moto version 3.1.16
  • boto3 version 1.24.36
  • botocore version 1.27.36

I am trying to create a bucket via:

  server_client = boto3.client("s3", endpoint_url="http://127.0.0.1:5000", aws_access_key_id="test", aws_secret_access_key="test")
  server_client.create_bucket(Bucket="my-test-bucket")

(2) I am getting a socket timeout exception.

Traceback (most recent call last):
  File "/lib/python3.9/site-packages/urllib3/connectionpool.py", line 426, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
  File "/lib/python3.9/site-packages/urllib3/connectionpool.py", line 421, in _make_request
    httplib_response = conn.getresponse()
  File "/..pyenv/versions/3.9.6/lib/python3.9/http/client.py", line 1349, in getresponse
    response.begin()
  File "/..pyenv/versions/3.9.6/lib/python3.9/http/client.py", line 316, in begin
    version, status, reason = self._read_status()
  File "/..pyenv/versions/3.9.6/lib/python3.9/http/client.py", line 277, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "/..pyenv/versions/3.9.6/lib/python3.9/socket.py", line 704, in readinto
    return self._sock.recv_into(b)
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/lib/python3.9/site-packages/botocore/httpsession.py", line 253, in send
    urllib_response = conn.urlopen(
  File "/lib/python3.9/site-packages/urllib3/connectionpool.py", line 726, in urlopen
tearDown
    retries = retries.increment(
  File "/lib/python3.9/site-packages/urllib3/util/retry.py", line 386, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/lib/python3.9/site-packages/urllib3/packages/six.py", line 735, in reraise
    raise value
  File "/lib/python3.9/site-packages/urllib3/connectionpool.py", line 670, in urlopen
    httplib_response = self._make_request(
  File "/lib/python3.9/site-packages/urllib3/connectionpool.py", line 428, in _make_request
    self._raise_timeout(err=e, url=url, timeout_value=read_timeout)
  File "/lib/python3.9/site-packages/urllib3/connectionpool.py", line 335, in _raise_timeout
    raise ReadTimeoutError(
urllib3.exceptions.ReadTimeoutError: AWSHTTPConnectionPool(host='127.0.0.1', port=5000): Read timed out. (read timeout=60)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/xx/moto_test.py", line 28, in test_load_data_using_decorators
    server_client.create_bucket(Bucket="my-test-bucket")
  File "/lib/python3.9/site-packages/botocore/client.py", line 357, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/lib/python3.9/site-packages/botocore/client.py", line 647, in _make_api_call
    http, parsed_response = self._make_request(
  File "/lib/python3.9/site-packages/botocore/client.py", line 667, in _make_request
    return self._endpoint.make_request(operation_model, request_dict)
  File "/lib/python3.9/site-packages/botocore/endpoint.py", line 102, in make_request
    return self._send_request(request_dict, operation_model)
  File "/lib/python3.9/site-packages/botocore/endpoint.py", line 136, in _send_request
    while self._needs_retry(attempts, operation_model, request_dict,
  File "/lib/python3.9/site-packages/botocore/endpoint.py", line 228, in _needs_retry
    responses = self._event_emitter.emit(
  File "/lib/python3.9/site-packages/botocore/hooks.py", line 356, in emit
    return self._emitter.emit(aliased_event_name, **kwargs)
  File "/lib/python3.9/site-packages/botocore/hooks.py", line 228, in emit
    return self._emit(event_name, kwargs)
  File "/lib/python3.9/site-packages/botocore/hooks.py", line 211, in _emit
    response = handler(**kwargs)
  File "/lib/python3.9/site-packages/botocore/retryhandler.py", line 183, in __call__
    if self._checker(attempts, response, caught_exception):
  File "/lib/python3.9/site-packages/botocore/retryhandler.py", line 250, in __call__
    should_retry = self._should_retry(attempt_number, response,
  File "/lib/python3.9/site-packages/botocore/retryhandler.py", line 277, in _should_retry
    return self._checker(attempt_number, response, caught_exception)
  File "/lib/python3.9/site-packages/botocore/retryhandler.py", line 316, in __call__
    checker_response = checker(attempt_number, response,
  File "/lib/python3.9/site-packages/botocore/retryhandler.py", line 222, in __call__
    return self._check_caught_exception(
  File "/lib/python3.9/site-packages/botocore/retryhandler.py", line 359, in _check_caught_exception
    raise caught_exception
  File "/lib/python3.9/site-packages/botocore/endpoint.py", line 200, in _do_get_response
    http_response = self._send(request)
  File "/lib/python3.9/site-packages/botocore/endpoint.py", line 244, in _send
    return self.http_session.send(request)
  File "/lib/python3.9/site-packages/botocore/httpsession.py", line 288, in send
    raise ReadTimeoutError(endpoint_url=request.url, error=e)
botocore.exceptions.ReadTimeoutError: Read timeout on endpoint URL: "http://127.0.0.1:5000/my-test-bucket"

(3) Additionally, the rest api is not accessible via http://127.0.0.1:5000/moto-api

 root@xxx:~# moto_server -H 0.0.0.0 &
 * Running on all addresses (0.0.0.0)
   WARNING: This is a development server. Do not use it in a production deployment.
 * Running on http://127.0.0.1:5000
127.0.0.1 - - [25/Jul/2022 08:14:43] "GET /moto-api HTTP/1.1" 404 -
root@xxx:~# curl http://127.0.0.1:5000/moto-api
127.0.0.1 - - [25/Jul/2022 08:20:08] "GET /moto-api HTTP/1.1" 404 -
<!doctype html>
<html lang=en>
<title>404 Not Found</title>
<h1>Not Found</h1>
<p>The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.</p>

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:3
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
bblommerscommented, Jul 25, 2022

Hi @MamedovaMaria, which version of werkzeug do you have installed? If it’s the latest (2.2.x), try downgrading it to 2.1.2.

4reactions
NFarringtoncommented, Jul 25, 2022

I’ve been having a similar issue and can confirm downgrading werkzeug from 2.2.x to 2.1.x has fixed this for me.

Read more comments on GitHub >

github_iconTop Results From Across the Web

HTTPSConnectionPool(host='pypi.python.org', port=443) with ...
How to solve ReadTimeoutError: HTTPSConnectionPool(host='pypi.python.org', port=443) with pip? ; in main status = self.run(options, args) File "/ ...
Read more >
Moto Documentation - Read the Docs
With a decorator wrapping, all the calls to S3 are automatically mocked out. import boto3 from moto import mock_s3 from mymodule import MyModel....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found