redis/jedis · error · JedisException

No connections available from connection provider

Error message

No connections available from connection provider

What it means

Thrown by the AggregateIterator constructor when the ConnectionProvider's primary-nodes connection map is empty, meaning there is no shard connection available to run the FT.AGGREGATE command. The library cannot route the aggregation without at least one pooled or direct connection entry, so it fails fast during initialization instead of failing later inside next().

Solutions

  1. Check how the ConnectionProvider is built and ensure at least one primary node/pool is configured before creating the iterator
  2. Verify cluster/sentinel topology is reachable and nodes are discovered (check host/port and startup_nodes config)
  3. Confirm you are using the correct provider type for your deployment (cluster provider for cluster mode, not a bare/single provider with no nodes)
  4. Wrap iterator construction in try-catch for JedisException and surface a clear configuration error to the caller

Example fix

// before
AggregateIterator it = new AggregateIterator(providerWithNoNodes, "idx", aggr); // JedisException
// after
Map<?, ?> connMap = provider.getPrimaryNodesConnectionMap();
if (connMap.isEmpty()) {
  throw new IllegalStateException("Configure at least one Redis node before running aggregations");
}
AggregateIterator it = new AggregateIterator(provider, "idx", aggr);
Defensive patterns

Strategy: validation

Validate before calling

Map<?, ?> connMap = connectionProvider.getPrimaryNodesConnectionMap();
if (connMap == null || connMap.isEmpty()) {
  throw new IllegalStateException("ConnectionProvider has no primary node connections; check client/node configuration");
}

Type guard

boolean hasConnections(ConnectionProvider p) {
  Map<?, ?> m = p.getPrimaryNodesConnectionMap();
  return m != null && !m.isEmpty();
}

Try / catch

try {
  AggregateIterator it = new AggregateIterator(provider, indexName, aggr);
} catch (JedisException e) {
  // no connections available — fix provider config before retrying
  throw new ConfigurationException("No Redis nodes configured for aggregation", e);
}

Prevention

When it happens

Trigger: Creating a new AggregateIterator (e.g. via a search/aggregation iteration API) while the underlying ConnectionProvider has no primary node connections registered — e.g. the provider was built with an empty node list, all nodes were removed, or the provider is not cluster/pool-backed as expected.

Common situations: Misconfigured JedisCluster or provider built without nodes; cluster topology discovered as empty (all masters down or excluded); calling aggregation before the client has connected to any shard; constructing AggregateIterator manually with a stubbed or miswired ConnectionProvider in tests.

Understand the failure class

Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.

Related errors


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

Appendix: source

Thrown at src/main/java/redis/clients/jedis/search/aggr/AggregateIterator.java:92

   * Creates a new AggregateIterator.
   * @param connectionProvider the connection provider for cluster/standalone Redis
   * @param indexName the search index name
   * @param aggregationBuilder the aggregation query with cursor configuration
   * @throws IllegalArgumentException if aggregation doesn't have cursor configured
   */
  public AggregateIterator(ConnectionProvider connectionProvider, String indexName,
      AggregationBuilder aggregationBuilder) {
    if (!aggregationBuilder.isWithCursor()) {
      throw new IllegalArgumentException("AggregationBuilder must have cursor configured");
    }

    this.indexName = indexName;
    this.batchSize = aggregationBuilder.getCursorCount();

    // Get connection pool entry - use getPrimaryNodesConnectionMap() to get pool-based connections
    Map<?, ?> connectionMap = connectionProvider.getPrimaryNodesConnectionMap();
    if (connectionMap.isEmpty()) {
      throw new JedisException("No connections available from connection provider");
    }
    // Randomly select an entry from the map to distribute load across shards
    List<? extends Map.Entry<?, ?>> entries = new ArrayList<>(connectionMap.entrySet());
    this.connectionEntry = entries.get(ThreadLocalRandom.current().nextInt(entries.size()));

    // Execute initial aggregation command
    initializeAggregation(aggregationBuilder);
  }

  @Override
  public boolean hasNext() {
    return aggrCommandResult != null || cursorId != null && cursorId > 0;
  }

  @Override
  public AggregationResult next() {
    if (!hasNext()) {
      throw new NoSuchElementException("No more aggregation results available");

View on GitHub (pinned to 6dac31d4c2)