redis/jedis · critical · JedisClusterOperationException

No nodes to initialize cluster slots cache.

Error message

No nodes to initialize cluster slots cache.

What it means

ClusterConnectionProvider.initializeSlotsCache() refuses to start the cluster slot cache when the supplied set of seed nodes is empty, throwing JedisClusterOperationException. Without at least one seed node, Jedis cannot discover the cluster topology or slot mapping.

Solutions

  1. Pass at least one valid cluster seed node, e.g. new HashSet<>(Set.of(new HostAndPort("127.0.0.1", 7000))).
  2. Fix the config/env parsing that yields an empty node list and log/fail early if the list is empty.
  3. Verify cluster node host/port values are populated before constructing the client.

Example fix

// before
Set<HostAndPort> nodes = parseNodes(config); // may be empty
JedisCluster cluster = new JedisCluster(nodes);
// after
Set<HostAndPort> nodes = parseNodes(config);
if (nodes.isEmpty()) throw new IllegalStateException("No cluster nodes configured");
JedisCluster cluster = new JedisCluster(nodes);
Defensive patterns

Strategy: validation

Validate before calling

if (nodes == null || nodes.isEmpty()) throw new IllegalStateException("At least one cluster seed node is required");
JedisCluster cluster = new JedisCluster(nodes, clientConfig);

Type guard

boolean hasSeedNodes(Set<HostAndPort> nodes) { return nodes != null && !nodes.isEmpty(); }

Try / catch

try {
  cluster = new JedisCluster(nodes);
} catch (JedisClusterOperationException e) {
  log.error("No cluster seed nodes configured", e);
  throw new IllegalStateException("Cluster client requires seed nodes", e);
}

Prevention

When it happens

Trigger: Creating a JedisCluster / ClusterConnectionProvider with an empty Set<HostAndPort> for clusterNodes, or with a host/port set that was filtered to nothing.

Common situations: Reading cluster node addresses from config/env that failed to parse; building the node set programmatically with a filter that removed all entries; constructing the client before config loading finished.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


AI-assisted analysis of redis/jedis@6dac31d4c2 (2026-09-08). Data as JSON: /api/errors/f7bde28bca2216d3. Report an issue: GitHub.

Appendix: source

Thrown at src/main/java/redis/clients/jedis/providers/ClusterConnectionProvider.java:69

    initializeSlotsCache(clusterNodes, clientConfig);
  }

  public ClusterConnectionProvider(Set<HostAndPort> clusterNodes, JedisClientConfig clientConfig,
      GenericObjectPoolConfig<Connection> poolConfig, Duration topologyRefreshPeriod) {
    this.cache = new JedisClusterInfoCache(clientConfig, poolConfig, clusterNodes, topologyRefreshPeriod);
    initializeSlotsCache(clusterNodes, clientConfig);
  }

  @Experimental
  public ClusterConnectionProvider(Set<HostAndPort> clusterNodes, JedisClientConfig clientConfig, Cache clientSideCache,
      GenericObjectPoolConfig<Connection> poolConfig, Duration topologyRefreshPeriod) {
    this.cache = new JedisClusterInfoCache(clientConfig, clientSideCache, poolConfig, clusterNodes, topologyRefreshPeriod);
    initializeSlotsCache(clusterNodes, clientConfig);
  }

  private void initializeSlotsCache(Set<HostAndPort> startNodes, JedisClientConfig clientConfig) {
    if (startNodes.isEmpty()) {
      throw new JedisClusterOperationException("No nodes to initialize cluster slots cache.");
    }

    ArrayList<HostAndPort> startNodeList = new ArrayList<>(startNodes);
    Collections.shuffle(startNodeList);

    JedisException firstException = null;
    for (HostAndPort hostAndPort : startNodeList) {
      try (Connection jedis = new Connection(hostAndPort, clientConfig)) {
        cache.discoverClusterNodesAndSlots(jedis);
        return;
      } catch (JedisException e) {
        if (firstException == null) {
          firstException = e;
        }
        // try next nodes
      }
    }

View on GitHub (pinned to 6dac31d4c2)