Download

ERR DB index is out of range

You asked for a database number this server doesn’t have: databases are numbered from 0, and there are 16 (0 to 15) unless the databases setting says otherwise. A cluster, Redis Cloud and some hosted services have database 0 only. Use a number that exists, or key prefixes instead.

Redis error ERR· Tested on Redis 8.10.2 and Valkey 8.1.10 (and temporary clusters)· Updated 11 October 2026

ERR DB index is out of range

What it means

A standalone Redis server holds several numbered databases, separate sets of keys on one server. They’re numbered from 0, and the databases setting decides how many there are: 16 by default, so 0 to 15. Asking for one past the end, with SELECT, MOVE, COPY … DB or a client’s database setting, gets:

(error) ERR DB index is out of range

The connection stays on the database it was using. A number that isn’t a number at all (SELECT abc) gets ERR value is not an integer or out of range instead.

A cluster has one database, 0, and refuses SELECT with any other number:

(error) ERR SELECT is not allowed in cluster mode

Valkey 9.0 and later support numbered databases in cluster mode, its documentation says; Valkey 8.1.10 refused SELECT 1 in a cluster with the message above.

Common causes

  1. A database number in the connection URL or settings that the server doesn’t have: redis://host:6379/16 on a server with 16 databases, or a number carried over from another server that was set up with more.
  2. A managed service with fewer databases. Redis Cloud (and Redis Software) don’t support databases other than 0, their documentation says. Other providers may set their own databases value.
  3. A cluster: Redis Cluster, Valkey Cluster before 9.0, or ElastiCache with cluster mode enabled, where any SELECT other than 0 fails.
  4. A database number that’s off by one, counting from 1.

How to fix it

See how many databases the server has

CONFIG GET databases
INFO keyspace

databases is the count (16 means 0 to 15); INFO keyspace lists the ones that hold keys (db0:keys=…). On a managed service where CONFIG isn’t available, INFO keyspace still works, and the provider’s documentation gives the count.

Use a database that exists

Change the number in your connection settings or URL (the number after the last / in redis://host:6379/2). CLIENT INFO shows which database the current connection is using (db=…).

Watch for this with redis-cli, which doesn’t stop at this error: with -n 16 it prints SELECT 16 failed: ERR DB index is out of range and runs your command on database 0.

Raise the count, on a server you run

databases can’t change while the server runs (CONFIG SET databases 32 replies ERR CONFIG SET failed (possibly related to argument 'databases') - can't set immutable config). Set it in redis.conf or on the command line, and restart:

redis-server --databases 32

On a cluster or Redis Cloud, use key prefixes

Where there’s only database 0, separate data by key name instead: app1:user:1, app2:user:1. Prefixes also make it easy to find and delete one group of keys (SCAN 0 MATCH app1:*). Remove the database number from the connection settings.

Reproduce it

Redis 8.10.2 and Valkey 8.1.10 test servers (16 databases), signed in with redis-cli:

SELECT 16
(error) ERR DB index is out of range
SELECT 15
OK
SELECT -1
(error) ERR DB index is out of range
SELECT abc
(error) ERR value is not an integer or out of range
CONFIG GET databases
1) "databases"
2) "16"
MOVE seo:err:k 16
(error) ERR DB index is out of range
COPY seo:err:k seo:err:k2 DB 16
(error) ERR DB index is out of range

SELECT 100000 got the same error. redis-cli asked for database 16:

$ redis-cli -n 16 PING
SELECT 16 failed: ERR DB index is out of range
PONG

A temporary Redis 8.10.2 container started with --databases 32 accepted SELECT 20 and refused SELECT 32 with the same error; another, started with the default, refused CONFIG SET databases 32 as immutable.

On a temporary three-node Redis 8.10.2 cluster, and on a Valkey 8.1.10 one:

SELECT 1
(error) ERR SELECT is not allowed in cluster mode
SELECT 0
OK

In Inlet

The sidebar shows each database the server has (db0, db1…), so you pick one that exists rather than typing a number. On a cluster, Inlet works in database 0 only, and says so if you ask for another. When the server refuses a database number, Inlet shows the message and links to this page.

Inlet: a database client for the Mac

One native app for PostgreSQL, MySQL, SQL Server, SQLite, MongoDB and Redis. It explains errors where they happen, holds your edits until you save them, and keeps production read-only until you say so.

Version 0.1.0 · macOS 26 Tahoe or later · Apple silicon and Intel