redis: ReplyError: ERR DB index is out of range
Asked Answered
C

4

10

I ran redis using Docker like so:

docker run  --rm -p '6379:6379' -v "$redis_data_dir:/data" --name my_redis_server -d redis redis-server --appendonly 'yes'

in the past this worked fine, but now I get this error:

{ ReplyError: ERR DB index is out of range
    at parseError (/root/interos/repos/ntrs-cli/node_modules/redis-parser/lib/parser.js:179:12)
    at parseType (/root/interos/repos/ntrs-cli/node_modules/redis-parser/lib/parser.js:302:14)

command: { name: 'select', args: [ '20127' ] } }

It looks like it's trying to connect to db 20127, I am certain it's one of these four:

const client_db0 = new Redis(`redis://${conf["platform-build.public-dns"]}:6379/0`);
const client_db1 = new Redis(`redis://${conf["platform-build.public-dns"]}:6379/1`);
const client_db2 = new Redis(`redis://${conf["platform-build.public-dns"]}:6379/2`);
const client_db3 = new Redis(`redis://${conf["platform-build.public-dns"]}:6379/3`);

so is there some way to start redis up and tell it to add more databases? something like:

docker run  .... redis redis-server --appendonly 'yes' --db-count=16
Corabelle answered 25/9, 2019 at 21:18 Comment(0)
D
11

in file etc/redis/redis.conf change line databases 16 (by default, it has 16), most likely you need more than 16

by default, each DB index is responsible for 8 or 10 databases (don't remember), so by default you use only 2 indexes (0 and 1)

Dissection answered 26/1, 2021 at 0:1 Comment(0)
M
3

The SELECT command is used to pick which database you're using. 20127 is way beyond your configured limit of 16.

Either change databases in /etc/redis.conf to be higher, which is probably a bad idea for very large values like 20K, or pick a value in the range 0..15.

If you're not sure where 20127 is coming from, track it down in the originating code or configuration.

Matterhorn answered 25/9, 2019 at 21:23 Comment(0)
C
1

It was due to the extra whitespace that I had here:

 'platform-build.public-dns': ' 127.0.0.1'

Maybe the parser could be improved?

Corabelle answered 25/9, 2019 at 23:30 Comment(2)
It's usually not the job of the config tool to trim extraneous spaces, so it's just garbage-in, garbage-out.Matterhorn
Could throw a parsing error tho, instead of completely misinterpreting itCorabelle
E
0

When i stop my docker environment and execute

docker volume prune

Error ERR DB index is out of range (Redis::CommandError) dissapears.

Eberhart answered 24/10, 2022 at 14:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.