# error: context deadline exceeded (Client.Timeout exceeded while awaiting headers)

- **ID:** `go/http-request-timeout`
- **Domain:** go
- **Category:** network_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

HTTP 请求在指定时间内未完成，可能是服务器响应慢或网络延迟。

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 1.21 | active | — | — |

## Workarounds

1. **** (90% success)
   ```
   client := &http.Client{Timeout: 10 * time.Second}
   ```
2. **** (95% success)
   ```
   ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
req, _ := http.NewRequestWithContext(ctx, "GET", url, nil)
   ```

## Dead Ends

- **** — 会导致程序挂起，且不解决服务器响应慢的问题。 (80% fail)
- **** — 如果服务器持续慢，重试会加重负载。 (60% fail)
