# sql: connection pool exhausted: too many open connections (max_open_conns=10)

- **ID:** `go/sql-too-many-open-connections`
- **Domain:** go
- **Category:** resource_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Handlers acquire connections but never Close rows or return them, or MaxOpenConns is set too low for concurrency. Leaked *sql.Rows exhaust the pool.

## Version Compatibility

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

## Workarounds

1. **** (92% success)
   ```
   rows, err := db.QueryContext(ctx, q)
if err != nil { return err }
defer rows.Close()
for rows.Next() { ... }
return rows.Err()
   ```
2. **** (85% success)
   ```
   db.SetMaxOpenConns(50)
db.SetMaxIdleConns(25)
db.SetConnMaxLifetime(5*time.Minute)
   ```

## Dead Ends

- **** — Hides the leak and can exhaust the database server's connection limit. (80% fail)
- **** — Does not release leaked connections; just delays the failure. (90% fail)
