litellm - 💡(How to fix) Fix RedisCluster drops socket timeout kwargs [2 pull requests]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

RedisClusterCache does not pass socket_timeout or socket_connect_timeout through to redis.RedisCluster, so Redis cluster connections can hang even when those timeout values are configured in cache_params or router_settings.cache_kwargs.

This affects production Redis cluster deployments such as AWS ElastiCache Serverless / Valkey with cluster mode enabled.

Error Message

redis.RedisCluster(... socket_timeout=1, socket_connect_timeout=2) => RedisClusterException: Redis Cluster cannot be connected. Please provide at least one reachable node: Timeout connecting to server => elapsed 1.01s

Root Cause

litellm._redis.init_redis_cluster() filters cluster kwargs through _get_redis_cluster_kwargs() before calling redis.RedisCluster(...). The allow-list includes values like ssl, username, and max_connections, but not socket_timeout or socket_connect_timeout, so those configured values are silently dropped for Redis cluster clients.

Fix Action

Fixed

Code Example

from litellm.caching.caching import RedisClusterCache

RedisClusterCache(
    startup_nodes=[{"host": "redis-blackhole", "port": 6379}],
    ssl=True,
    socket_timeout=1,
    socket_connect_timeout=2,
)

---

redis.RedisCluster(... socket_timeout=1, socket_connect_timeout=2)
=> RedisClusterException: Redis Cluster cannot be connected. Please provide at least one reachable node: Timeout connecting to server
=> elapsed 1.01s
RAW_BUFFERClick to expand / collapse

Summary

RedisClusterCache does not pass socket_timeout or socket_connect_timeout through to redis.RedisCluster, so Redis cluster connections can hang even when those timeout values are configured in cache_params or router_settings.cache_kwargs.

This affects production Redis cluster deployments such as AWS ElastiCache Serverless / Valkey with cluster mode enabled.

Reproduction

Using the LiteLLM image with a TCP server that accepts connections on :6379 but never replies:

from litellm.caching.caching import RedisClusterCache

RedisClusterCache(
    startup_nodes=[{"host": "redis-blackhole", "port": 6379}],
    ssl=True,
    socket_timeout=1,
    socket_connect_timeout=2,
)

Expected: raises RedisClusterException quickly, consistent with direct redis.RedisCluster(...) behavior.

Observed: the LiteLLM RedisClusterCache construction continues hanging well past the configured timeout.

Direct redis-py behavior with the same kwargs does time out quickly:

redis.RedisCluster(... socket_timeout=1, socket_connect_timeout=2)
=> RedisClusterException: Redis Cluster cannot be connected. Please provide at least one reachable node: Timeout connecting to server
=> elapsed 1.01s

Root Cause

litellm._redis.init_redis_cluster() filters cluster kwargs through _get_redis_cluster_kwargs() before calling redis.RedisCluster(...). The allow-list includes values like ssl, username, and max_connections, but not socket_timeout or socket_connect_timeout, so those configured values are silently dropped for Redis cluster clients.

Proposed Fix

Add socket_timeout and socket_connect_timeout to _get_redis_cluster_kwargs() so they are forwarded to redis-py cluster clients.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

litellm - 💡(How to fix) Fix RedisCluster drops socket timeout kwargs [2 pull requests]