Redis Cluster mode only supports database 0 and disallows the SELECT command. This error occurs when your client attempts to switch databases in cluster mode, which is not supported by design.
Redis Cluster is a distributed version of Redis that shards data across multiple nodes. Unlike standalone Redis, which supports 16 separate databases (0-15) that you can switch between using the SELECT command, Redis Cluster deliberately restricts you to database 0 only. When running in cluster mode, the SELECT command is explicitly rejected to maintain architectural consistency and prevent the complexity of cross-database operations in a distributed system. This limitation is intentional—not a bug—and ensures that atomic operations remain possible without having to coordinate across multiple databases.
First, confirm that your Redis instance is actually running in cluster mode:
redis-cli -c info clusterLook for cluster_enabled: 1 in the output. If it shows 0, you are in standalone mode and can use SELECT.
Update your Redis connection configuration to remove any database number. Change from:
redis://host:6379/5
redis://host:6379/12To:
redis://host:6379Also remove any db, database, or select parameters from your client configuration.
If using a specific Redis client library, verify it is configured for cluster mode:
For ioredis (Node.js):
const redis = new Redis.Cluster([
{ host: 'host1', port: 6379 },
{ host: 'host2', port: 6379 }
]);For Predis (PHP):
$client = new Client('redis://host:6379');For redis-py (Python):
from rediscluster import RedisCluster
rc = RedisCluster(startup_nodes=[{"host": "host", "port": "6379"}])If you currently store data in multiple databases and are migrating to cluster mode, consolidate all data into database 0. Use the MOVE command to move keys:
# Connect to standalone Redis
redis-cli -n 1 # Select database 1
MOVE key_name 0 # Move to database 0Or use MIGRATE for remote migration:
MIGRATE host port key 0 timeoutIf your application architecture requires multiple separate databases, you have two options:
Option 1: Use standalone (non-cluster) Redis
- Set cluster mode to disabled in your Redis configuration
- In AWS ElastiCache, create a new cluster with "Cluster Mode Disabled"
- This allows you to use SELECT and multiple databases
Option 2: Use Redis with Cluster Mode Disabled
# In redis.conf
cluster-enabled noRedis Cluster is designed for horizontal scalability and high availability across multiple nodes. Supporting multiple databases in cluster mode would require coordinating state across nodes and make transactions significantly more complex. Therefore, this limitation is architectural, not accidental. If you are using AWS ElastiCache Serverless, it exclusively uses Cluster Mode Enabled and cannot be changed—you must redesign your application to use a single database (db0). For very large deployments, consider using Redis Streams or Hash-based key namespacing instead of database separation.
ERR Unbalanced XREAD list of streams
How to fix "ERR Unbalanced XREAD list" in Redis
ERR syntax error
How to fix "ERR syntax error" in Redis
ConnectionError: Error while reading from socket
ConnectionError: Error while reading from socket in redis-py
ERR unknown command
How to fix ERR unknown command in Redis
Command timed out
How to fix 'Command timed out' in ioredis