# http: request context canceled

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

## Root Cause

The client canceled the request or the server's context was canceled due to timeout or client disconnect, causing the HTTP handler to abort.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 1.17 | active | — | — |
| 1.20 | active | — | — |

## Workarounds

1. **** (90% success)
   ```
   Check for context cancellation and return early: if r.Context().Err() != nil { return }
   ```
2. **** (70% success)
   ```
   Use http.Server with ReadTimeout and WriteTimeout properly: &http.Server{ReadTimeout: 10*time.Second, WriteTimeout: 10*time.Second}
   ```

## Dead Ends

- **** — Processing continues but the client is gone; results are wasted and may cause resource leaks. (80% fail)
- **** — Long timeouts can lead to resource exhaustion and don't address client-initiated cancellations. (60% fail)
