# 503 Service Unavailable: Connection pool exhausted. Maximum connections to backend reached.

- **ID:** `api/rate-limit-connection-pool-exhausted`
- **Domain:** api
- **Category:** resource_error
- **Verification:** ai_generated
- **Fix Rate:** 78%

## Root Cause

Client-side HTTP connection pool (e.g., requests.Session or Node.js http.Agent) has no available connections due to slow responses or leaks.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| Python requests 2.31.0 | active | — | — |
| Node.js http module 18.x | active | — | — |
| Go net/http 1.21 | active | — | — |

## Workarounds

1. **Increase connection pool size and add idle timeout. In Python requests: session = requests.Session(); adapter = requests.adapters.HTTPAdapter(pool_connections=100, pool_maxsize=100, max_retries=3); session.mount('https://', adapter); session.mount('http://', adapter)** (80% success)
   ```
   Increase connection pool size and add idle timeout. In Python requests: session = requests.Session(); adapter = requests.adapters.HTTPAdapter(pool_connections=100, pool_maxsize=100, max_retries=3); session.mount('https://', adapter); session.mount('http://', adapter)
   ```
2. **Enable connection reuse with keepalive and reduce request timeout. For Node.js: const agent = new http.Agent({ keepAlive: true, maxSockets: 25, timeout: 60000 });** (75% success)
   ```
   Enable connection reuse with keepalive and reduce request timeout. For Node.js: const agent = new http.Agent({ keepAlive: true, maxSockets: 25, timeout: 60000 });
   ```
3. **Add retry with exponential backoff for 503 errors to allow connections to be released.** (70% success)
   ```
   Add retry with exponential backoff for 503 errors to allow connections to be released.
   ```

## Dead Ends

- **** — Increasing max_connections arbitrarily without addressing slow backend responses leads to memory exhaustion and worse performance. (60% fail)
- **** — Restarting the application without adjusting timeout settings causes the pool to exhaust again quickly under load. (70% fail)
