# java.net.SocketTimeoutException: timeout. ConnectionPool idle timeout expired. No connection available.

- **ID:** `android/okhttp-connection-pool-timeout`
- **Domain:** android
- **Category:** network_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

OkHttp's connection pool has no idle connections available for reuse after the idle timeout (default 5 minutes), and a new connection cannot be established within the configured connect timeout due to network issues or server unavailability.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| OkHttp 4.11.0 | active | — | — |
| OkHttp 4.12.0 | active | — | — |
| Android 13 (API 33) | active | — | — |

## Workarounds

1. **Increase the idle timeout and pool size in OkHttpClient: `val client = OkHttpClient.Builder().connectionPool(ConnectionPool(10, 10, TimeUnit.MINUTES)).connectTimeout(15, TimeUnit.SECONDS).build()`** (85% success)
   ```
   Increase the idle timeout and pool size in OkHttpClient: `val client = OkHttpClient.Builder().connectionPool(ConnectionPool(10, 10, TimeUnit.MINUTES)).connectTimeout(15, TimeUnit.SECONDS).build()`
   ```
2. **Implement retry logic with exponential backoff in your network call: `retryWhen { cause, attempt -> if (cause is SocketTimeoutException && attempt < 3) { delay((1000L * Math.pow(2.0, attempt.toDouble())).toLong()) true } else false }` (Kotlin coroutines example).** (80% success)
   ```
   Implement retry logic with exponential backoff in your network call: `retryWhen { cause, attempt -> if (cause is SocketTimeoutException && attempt < 3) { delay((1000L * Math.pow(2.0, attempt.toDouble())).toLong()) true } else false }` (Kotlin coroutines example).
   ```

## Dead Ends

- **** — The error is about connection pool idle timeout, not connect timeout. Increasing connect timeout does not prevent pool exhaustion; it only delays the failure. (90% fail)
- **** — Disabling pooling forces a new connection for every request, which can cause performance degradation and increase the likelihood of timeout errors under load. (75% fail)
