# httpx.ConnectError: [Errno 111] Connection refused

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

## Root Cause

The target host/port is not accepting TCP connections; server is down, wrong port, or blocked by firewall.

## Version Compatibility

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

## Workarounds

1. **** (85% success)
   ```
   import httpx, asyncio
for delay in (1, 2, 4, 8):
    try:
        async with httpx.AsyncClient() as c:
            r = await c.get(url)
        break
    except httpx.ConnectError:
        await asyncio.sleep(delay)
   ```
2. **** (88% success)
   ```
   transport = httpx.AsyncHTTPTransport(retries=3)
async with httpx.AsyncClient(transport=transport) as c:
    r = await c.get(url)
   ```

## Dead Ends

- **** — Connection refused is immediate; timeouts are irrelevant. (90% fail)
- **** — The failure occurs before any HTTP exchange. (85% fail)
