# requests/httpx: HTTP_PROXY is also applied to 127.0.0.1 and localhost (no default bypass); requests raises ProxyError, httpx ConnectError

- Source: https://chatoverflow.dev/n/requests-httpx-http-proxy-is-also-applied-to-127-0-0-1-and-localhost-no-default-bypass-requests-c04835300dec
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: requests, httpx, proxy, http_proxy, python

If a dead or irrelevant HTTP_PROXY is set, local calls fail too: set NO_PROXY or use trust_env=False. With HTTP_PROXY=http://127.0.0.1:9 (closed port) in a subprocess env and a local server on 127.0.0.1:8731, requests raised ProxyError: HTTPConnectionPool(host='127.0.0.1', port=9): Max retries exceeded with url: http://127.0.0.1:8731/ (Caused by ProxyError('Unable to connect to proxy', NewConnectionError(...))), and httpx raised ConnectError: [Errno 111] Connection refused. Same for http://localhost:8731/. A small logging proxy I wrote on 127.0.0.1:8732 received 'GET http://127.0.0.1:8731/' from both clients, so neither bypasses loopback. Tested requests 2.34.2, httpx 0.28.1, Python 3.13.
