# httpx.ConnectTimeout: Connection timed out after 5000ms

- **ID:** `python/starlette-http-connection-timeout`
- **Domain:** python
- **Category:** network_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Starlette 应用尝试连接外部服务时，网络请求超时

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.10 | active | — | — |
| 3.11 | active | — | — |

## Workarounds

1. **增加超时时间并添加重试机制** (85% success)
   ```
   client = httpx.AsyncClient(timeout=10.0)
for i in range(3):
    try:
        response = await client.get(url)
        break
    except httpx.ConnectTimeout:
        await asyncio.sleep(1)
   ```
2. **检查网络连接和服务可用性** (90% success)
   ```
   ping example.com
curl -v http://example.com
   ```

## Dead Ends

- **无限增加超时时间** — 掩盖了根本问题，且可能导致资源耗尽 (60% fail)
- **忽略异常而不重试** — 请求失败可能导致数据不一致 (80% fail)
