BerriAI/litellm · error · ValueError

Both 'sentinel_nodes' and 'service_name' are required for…

Error message

Both 'sentinel_nodes' and 'service_name' are required for Redis Sentinel.

What it means

_init_redis_sentinel() in litellm/_redis.py requires both sentinel_nodes and service_name in redis_kwargs; missing either raises ValueError before the redis.Sentinel client is built. service_name selects which monitored master to use (sentinel.master_for(service_name)); sentinel_nodes lists the sentinel process addresses.

Solutions

  1. Pass both: RedisCache(sentinel_nodes=[{"host":"sentinel-1","port":26379}], service_name="mymaster")
  2. Or supply the equivalent env/config keys your deployment uses for sentinel (e.g. REDIS_SERVICE_NAME alongside sentinel nodes)
  3. Confirm the service_name matches the monitored master name configured on the sentinels (SENTINEL monitor <name> ...)
  4. Typo-check keys: sentinel_nodes (plural) and service_name exactly

Example fix

# before
RedisCache(sentinel_nodes=[{"host":"sentinel","port":26379}])
# ValueError: Both 'sentinel_nodes' and 'service_name' are required for Redis Sentinel.

# after
RedisCache(
    sentinel_nodes=[{"host":"sentinel-1","port":26379}, {"host":"sentinel-2","port":26379}],
    service_name="mymaster",
)
Defensive patterns

Strategy: validation

Validate before calling

def validate_sentinel_config(cfg: dict) -> None:
    nodes = cfg.get("sentinel_nodes")
    service = cfg.get("service_name")
    if not nodes or not service:
        raise ValueError(
            "Redis Sentinel needs both sentinel_nodes=[{host,port},...] and "
            "service_name=<monitored master name>"
        )

Prevention

When it happens

Trigger: Configuring cache with sentinel support: passing sentinel_nodes=[{'host':..,'port':26379}] but omitting service_name (or vice versa); env-based setup where REDIS_SERVICE_NAME is unset; typos like service or master_name instead of service_name.

Common situations: Migrating from a plain Redis deployment to Redis Sentinel and copying the nodes but not the master name; Helm chart values missing the sentinel service name; assuming the master name defaults to 'mymaster' (litellm requires it explicitly).

Related errors


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/e4a86ea683606a30. Report an issue: GitHub.

Appendix: source

Thrown at litellm/_redis.py:537

    args: Final = _get_redis_kwargs()
    for arg in redis_kwargs:
        if arg in args:
            connection_kwargs[arg] = redis_kwargs[arg]

    return connection_kwargs


def _init_redis_sentinel(redis_kwargs) -> redis.Redis:
    sentinel_nodes: Final = redis_kwargs.get("sentinel_nodes")
    sentinel_password: Final = redis_kwargs.get("sentinel_password")
    service_name: Final = redis_kwargs.get("service_name")
    connection_kwargs: Final = _get_redis_sentinel_connection_kwargs(redis_kwargs)
    connection_kwargs.setdefault("socket_timeout", REDIS_SOCKET_TIMEOUT)
    sentinel_kwargs: Final = dict(connection_kwargs)
    sentinel_kwargs["password"] = sentinel_password

    if not sentinel_nodes or not service_name:
        raise ValueError("Both 'sentinel_nodes' and 'service_name' are required for Redis Sentinel.")

    verbose_logger.debug("init_redis_sentinel: sentinel nodes are being initialized.")

    # Set up the Sentinel client
    sentinel: Final = redis.Sentinel(
        sentinel_nodes,
        sentinel_kwargs=sentinel_kwargs,
    )

    # Return the master instance for the given service

    return sentinel.master_for(service_name, **connection_kwargs)


def _init_async_redis_sentinel(redis_kwargs) -> async_redis.Redis:
    sentinel_nodes: Final = redis_kwargs.get("sentinel_nodes")
    sentinel_password: Final = redis_kwargs.get("sentinel_password")
    service_name: Final = redis_kwargs.get("service_name")

View on GitHub (pinned to 77b7c6c40c)