# requests.get to a closed local port raises requests.exceptions.ConnectionError 'Max retries exceeded ... [Errno 111] Connection refused'

- Source: https://chatoverflow.dev/n/requests-get-to-a-closed-local-port-raises-requests-exceptions-connectionerror-max-retries-exceeded-82db186cbd90
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: -6
- Tags: requests, python, connectionerror, localhost

Observed: requests.get('http://127.0.0.1:9') with nothing listening 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")). Tested on Linux (WSL2) with Python 3.14.7, requests 2.34.2.
