BerriAI/litellm · error · ValueError
REDIS_CLUSTER_NODES environment variable is not valid JSON.
Error message
REDIS_CLUSTER_NODES environment variable is not valid JSON. Please ensure it's properly formatted.
What it means
Error "REDIS_CLUSTER_NODES environment variable is not valid JSON. Please ensure it's properly formatted." thrown in BerriAI/litellm.
Source
Thrown at litellm/_redis.py:487
and redis_kwargs["startup_nodes"] is not None
or "sentinel_nodes" in redis_kwargs
and redis_kwargs["sentinel_nodes"] is not None
):
pass
elif "host" not in redis_kwargs or redis_kwargs["host"] is None:
raise ValueError("Either 'host' or 'url' must be specified for redis.")
# litellm.print_verbose(f"redis_kwargs: {redis_kwargs}")
return redis_kwargs
def init_redis_cluster(redis_kwargs) -> redis.RedisCluster:
_redis_cluster_nodes_in_env: Final[str | None] = get_secret("REDIS_CLUSTER_NODES")
if _redis_cluster_nodes_in_env is not None:
try:
redis_kwargs["startup_nodes"] = json.loads(_redis_cluster_nodes_in_env)
except json.JSONDecodeError:
raise ValueError(
"REDIS_CLUSTER_NODES environment variable is not valid JSON. Please ensure it's properly formatted."
)
verbose_logger.debug("init_redis_cluster: startup nodes are being initialized.")
from redis.cluster import ClusterNode
args: Final = _get_redis_cluster_kwargs()
cluster_kwargs: Final = {}
for arg in redis_kwargs:
if arg in args:
cluster_kwargs[arg] = redis_kwargs[arg]
new_startup_nodes: Final[list[ClusterNode]] = []
for item in redis_kwargs["startup_nodes"]:
new_startup_nodes.append(ClusterNode(**item))
cluster_kwargs.pop("startup_nodes", None)View on GitHub (pinned to 6c2dcb801b)
Solutions
- Fix REDIS_CLUSTER_NODES to be valid JSON, e.g. '[{"host": "h1", "port": 6379}]'.
When it happens
Trigger: Thrown at litellm/_redis.py:487 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/104a2cb06510a693.
Report an issue: GitHub.