# Jedis: redis.clients.jedis.exceptions.JedisException: Could not get a resource from the pool

**Code:** `JedisException: Could not get a resource from the pool` · **Category:** Redis · **Seen on:** Redis, Java

The Jedis connection pool had no available connection within the wait time, or couldn't create one.

## Meaning

Check the root cause (nested exception): Redis unreachable, pool exhausted (`maxTotal`), or connections leaked (not closed). Use try-with-resources (`try (Jedis j = pool.getResource())`), increase `maxTotal`/`maxWaitMillis`, and verify Redis connectivity/auth.

## Common causes

- Pool exhausted (`maxTotal` too small)
- Connections not returned (missing close)
- Redis down/unreachable (nested JedisConnectionException)
- Wrong host/password
- Long blocking commands holding connections

## Quick fix

1. Use try-with-resources for every `getResource()`
2. Tune `JedisPoolConfig.setMaxTotal(128)` and `setMaxWait(Duration.ofSeconds(2))`
3. Check the nested cause and Redis reachability

## Detailed fix by platform

### Java

1. `try (Jedis jedis = pool.getResource()) { jedis.set("k","v"); }`

## How to diagnose

1. **Cause** — Nested exception?
2. **Close** — try-with-resources?
3. **Pool** — maxTotal?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/redis/jedis-could-not-get-a-resource-from-the-pool)
