3

I'm trying to connect to a hosted redis on IrisCouch that I provisioned via Nodejitsu.

What I think are the relevant parts of my server.js :

var redisUrl = require('url').parse(config.REDIS_CONNECTION_URI);
var client = require('redis').createClient(redisUrl.port, redisUrl.hostname);

I don't have any interaction with the client in my server.js yet, which is why I think it's weird that it's throwing the "operation not permitted", since basicly the only operation I do is to connect. I don't have a redis.conf file and I believe I shouldn't need one since I do not host the redis instance myself.

Log:

 Express server listening on port 3000

/Users/soroushhakami/dev/projects/projectx/node_modules/redis/index.js:504
                throw callback_err;
                      ^
Error: Ready check failed: ERR operation not permitted
    at RedisClient.on_info_cmd (/Users/soroushhakami/dev/projects/projectx/node_modules/redis/index.js:317:35)
    at Command.RedisClient.ready_check.send_anyway [as callback] (/Users/soroushhakami/dev/projects/projectx/node_modules/redis/index.js:365:14)
    at RedisClient.return_error (/Users/soroushhakami/dev/projects/projectx/node_modules/redis/index.js:500:25)
    at ReplyParser.RedisClient.init_parser (/Users/soroushhakami/dev/projects/projectx/node_modules/redis/index.js:260:14)
    at ReplyParser.EventEmitter.emit (events.js:96:17)
    at ReplyParser.send_error (/Users/soroushhakami/dev/projects/projectx/node_modules/redis/lib/parser/javascript.js:293:10)
    at ReplyParser.execute (/Users/soroushhakami/dev/projects/projectx/node_modules/redis/lib/parser/javascript.js:176:22)
    at RedisClient.on_data (/Users/soroushhakami/dev/projects/projectx/node_modules/redis/index.js:476:27)
    at Socket.<anonymous> (/Users/soroushhakami/dev/projects/projectx/node_modules/redis/index.js:79:14)
    at Socket.EventEmitter.emit (events.js:96:17)

Any ideas on what could be the problem?

Soroush Hakami
  • 5,226
  • 15
  • 66
  • 99
  • Are you sure the Redis server doesn't require authentication? – robertklep Apr 06 '13 at 08:53
  • It does. But I was going to auth using client.auth(password) after the client I had created the client. Also, the error is saying that the Ready check failed, not that the Auth failed. But maybe the error message does not convey the actual problem? – Soroush Hakami Apr 06 '13 at 09:07
  • [This](https://github.com/mranney/node_redis#clientauthpassword-callback) says: '*Your call to client.auth() should not be inside the ready handler. If you are doing this wrong, client will emit an error that looks something like this Error: Ready check failed: ERR operation not permitted*', which is what you're seeing. – robertklep Apr 06 '13 at 10:42
  • I see. But I'm not making any calls to client.auth here in this code, yet it fails. – Soroush Hakami Apr 07 '13 at 07:36
  • i used an existing remote redis we had and forgot it had a requirepass set in its redis.conf – Robot70 May 19 '17 at 17:55

2 Answers2

11

You need to call client.auth() directly after creating the client:

var client = require('redis').createClient(redisUrl.port, redisUrl.hostname);
client.auth(PASSWORD);

The confusing thing is that when you don't call .auth() on client but nothing else either, you will get a failed ready check error.

robertklep
  • 198,204
  • 35
  • 394
  • 381
2

I usually have that error while CLI-testing.

I guess the issue is that the call to auth should be made before the ready event is emitted (as robertklep mentions). When you're testing using the CLI the client starts connecting as soon as you hit the enter key at the end of your var client = redis.createClient(port, host); line and probably sends an IDLE command of some sort before you even get the chance to send the AUTH command, which triggers the ERR operation not permitted error.

tl;dr

when CLI-testing, create your redis client with the following code:

var redis = require('redis');
function createClient(port, host, pass) {
    var client = redis.createClient(port, host);
    client.auth(pass);
    return client;
}

var r = createClient(<MYPORT>, <MYHOST>, <MYPASS>);
Community
  • 1
  • 1