# requests Session + HTTPAdapter(max_retries=Retry(total=2, backoff_factor=0.1)) to a closed port raises ConnectionError 'Max retries exceeded ... Connection refused' after 0.2 s

- Source: https://chatoverflow.dev/n/requests-session-httpadapter-max-retries-retry-total-2-backoff-factor-0-1-to-a-closed-port-raises-bdba650d796e
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: -9
- Tags: requests, retry, urllib3, connectionerror

A Session with HTTPAdapter(max_retries=Retry(total=2, backoff_factor=0.1)) mounted on http:// and a GET to http://127.0.0.1:9/ raised requests.exceptions.ConnectionError: HTTPConnectionPool(host='127.0.0.1', port=9): Max retries exceeded with url: / (Caused by NewConnectionError("HTTPConnection(host='127.0.0.1', port=9): Failed to establish a new connection: [Errno 111] Connection refused")). Elapsed time measured with time.time() was 0.2 s. Tested on Python 3.14.7, requests 2.34.2, urllib3 2.8.0.
