How to fix ERR SELECT is not allowed in cluster mode in Redis
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.
Quick fix
Fixes ERR SELECT is not allowed in cluster mode
redis-cli -c info cluster- Verify you are using Redis Cluster mode
- Remove database number from connection string
- Check your client library configuration
- Migrate data to database 0 if needed
redis-cli -c info clusterERR SELECT is not allowed in cluster mode
What this error means
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.
Typical symptoms
- Application crashes or connection errors when connecting to AWS ElastiCache Redis Cluster
- Redis client library throws "ReplyError: ERR SELECT is not allowed in cluster mode"
- Sidekiq or other job queue frameworks fail when configured for cluster mode
- Redis connection string contains a database number (e.g., redis://host:port/12) but cluster mode is enabled
- Works in local development but fails in production with clustered Redis
Common causes
- Your application or Redis client is configured with a database number (e.g., SELECT 1, SELECT 5) when connecting to a Redis Cluster
- Client library defaults assume standalone Redis and attempt to select non-zero databases
- AWS ElastiCache is set to Cluster Mode Enabled (CME) or Serverless, which does not support multiple databases
- Migration from standalone Redis to cluster mode without updating application configuration
- Redis connection URL includes a database number suffix that is incompatible with cluster mode
How to fix "ERR SELECT is not allowed in cluster mode"
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 noAdvanced notes
Redis 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.
Frequently asked questions
- What does "ERR SELECT is not allowed in cluster mode" mean?
- 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.
- How do I fix "ERR SELECT is not allowed in cluster mode"?
- 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.
- What causes "ERR SELECT is not allowed in cluster mode"?
- Your application or Redis client is configured with a database number (e.g., SELECT 1, SELECT 5) when connecting to a Redis Cluster Client library defaults assume standalone Redis and attempt to select non-zero databases AWS ElastiCache is set to Cluster Mode Enabled (CME) or Serverless, which does not support multiple databases
- Is the "ERR SELECT is not allowed in cluster mode" error serious?
- It is a medium-severity error — more of a blocker than a risk. The steps above resolve it.
Official resources & further reading
- 📚Redis Official Documentation
- 📖Redis Documentation - SELECT command(Official Docs)
- 📖Redis Documentation - Cluster Specification(Official Docs)
- 🐙
- 🐙