# httpx.ConnectError: [Errno 111] Connection refused

- **ID:** `python/httpx-connect-error`
- **Domain:** python
- **Category:** network_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

The target host/port is not accepting connections — the service is down, bound to a different interface, or a firewall is blocking.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.8 | active | — | — |
| 3.9 | active | — | — |
| 3.10 | active | — | — |
| 3.11 | active | — | — |
| 3.12 | active | — | — |

## Workarounds

1. **** (95% success)
   ```
   Verify the service is reachable:

curl -v http://host:port/
ss -tlnp | grep :port
   ```
2. **** (90% success)
   ```
   In Docker Compose, use the service name (not localhost) as the host, and ensure depends_on with healthcheck.
   ```
3. **** (85% success)
   ```
   Add a circuit breaker with tenacity and surface a clear error to callers.
   ```

## Dead Ends

- **** — If the service is down, retries fail identically. (85% fail)
- **** — TLS is not involved; the TCP connect fails before handshake. (90% fail)
- **** — Connection refused is immediate, not a timeout. (95% fail)
