# error: http: Server closed

- **ID:** `go/net-http-server-shutdown-graceful-timeout`
- **Domain:** go
- **Category:** system_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

The HTTP server was shut down while handling requests, causing in-flight requests to fail with 'Server closed'.

## Version Compatibility

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

## Workarounds

1. **Use Shutdown with a context timeout and wait for connections to drain** (95% success)
   ```
   ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()
if err := server.Shutdown(ctx); err != nil { log.Fatal(err) }
   ```

## Dead Ends

- **Using Shutdown without waiting for active connections** — Active connections are terminated abruptly; use Shutdown with context. (70% fail)
