Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Redis auth error with Node.js and

Redis auth error with Node.js and


I can connect my Node app to Redis just fine without a Password, but when I add a password, nothing I do is right.

Here's my code right now, taken right from an example:

var redis = require('redis')
  , sio = require('')
  , RedisStore = sio.RedisStore
  , io = sio.listen();

var port = 6379
  , hostname = 'localhost'
  , password = 'password';

var redisClient = redis.createClient(port, hostname);
redisClient.auth(password, function (err) { if (err) throw err; });

var redisSubscriber = redis.createClient(port, hostname);
redisSubscriber.auth(password, function (err) { if (err) throw err; });

io.set('store', new RedisStore({ redisPub: redisClient, redisSub: redisSubscriber, redisClient: redisClient }));

On running the app, I get this stack trace:

                throw callback_err;
Error: Ready check failed: ERR operation not permitted
    at RedisClient.on_info_cmd (/home/eric/christmas/sockets/node_modules/
    at Command.RedisClient.ready_check.send_anyway [as callback] (/home/eric/christmas/sockets/node_modules/
    at RedisClient.return_error (/home/eric/christmas/sockets/node_modules/
    at RedisReplyParser.RedisClient.init_parser (/home/eric/christmas/sockets/node_modules/
    at RedisReplyParser.EventEmitter.emit (events.js:93:17)
    at RedisReplyParser.send_error (/home/eric/christmas/sockets/node_modules/
    at RedisReplyParser.execute (/home/eric/christmas/sockets/node_modules/
    at RedisClient.on_data (/home/eric/christmas/sockets/node_modules/
    at Socket. (/home/eric/christmas/sockets/node_modules/
    at Socket.EventEmitter.emit (events.js:93:17)

The line generating this is the final one - if I comment out the attempt to set the RedisStore, I do not get any errors.

I'm sure the password is right (I can verify it in redis-cli, and if I change the password to be wrong I can verify that the auth callbacks don't fire). This code also works if I remove the password and comment out the two auth lines.

All of the working examples on blog posts and docs and the like show that this should work, and I don't know why mine isn't. I don't know which part of the stack to look at.

Here's what the redis-cli monitor looks like when I run the code above:

1353227107.912512 [0] "auth" "password"
1353227107.912719 [0] "auth" "password"
1353227107.913470 [0] "info"
1353227107.913639 [0] "info"

And here's what redis-cli monitor shows if I turn off the password, comment out the auth lines above, and successfully run the app:

1353227252.401667 [0] "info"
1353227252.402020 [0] "info"
1353227252.402131 [0] "info"
1353227252.402423 [0] "info"
1353227252.402611 [0] "info"
1353227252.406254 [0] "subscribe" "handshake"
1353227252.406287 [0] "subscribe" "connect"
1353227252.406314 [0] "subscribe" "open"
1353227252.406321 [0] "subscribe" "join"
1353227252.406326 [0] "subscribe" "leave"
1353227252.406337 [0] "subscribe" "close"
1353227252.406354 [0] "subscribe" "dispatch"
1353227252.406372 [0] "subscribe" "disconnect"

The successful (passwordless) connection makes 5 "info" commands, and my unsuccessful (passworded) command makes 2 - and then dies on a call to an "on_info_cmd" method.

Can anyone make sense of this? Thanks for any help you can give.

Problem courtesy of: Konklone


I solved this by passing the redis module itself as an option to the RedisStore constructor.

io.set('store', new RedisStore({redis: redis, redisPub: redisClient, redisSub: redisSubscriber, redisClient: redisClient }));

This was necessary for the client objects to pass the instanceof RedisClient test and not be re-initialized without a password. Apparently, when RedisStore re-requires the redis module, redis clients created with the createClient method are members of some new class or something.

I figured this out by looking at a related issue someone was having on's issue #808.

Solution courtesy of: Konklone


View additional discussion.

This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

Redis auth error with Node.js and


Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription