# error: accept tcp :8080: accept4: too many open files

- **ID:** `go/too-many-open-files-goroutine-leak`
- **Domain:** go
- **Category:** resource_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Goroutines leak because HTTP response bodies are not closed or client connections are not drained, exhausting file descriptors.

## Version Compatibility

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

## Workarounds

1. **** (95% success)
   ```
   resp, err := http.Get(url)
if err != nil { return err }
defer resp.Body.Close()
io.Copy(io.Discard, resp.Body)
   ```
2. **** (90% success)
   ```
   ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel()
req, _ := http.NewRequestWithContext(ctx, "GET", url, nil)
resp, err := http.DefaultClient.Do(req)
   ```

## Dead Ends

- **** — Delays the crash; leaked descriptors keep accumulating and the process eventually dies again. (80% fail)
- **** — Treats the symptom; the leak persists and restart frequency increases. (85% fail)
