Search code examples
javascriptnode.jsexpressredisconnect-redis

External database with redis-connect?


I'm trying to connect to a 3rd party Redis database with connect-redis. Any idea what's wrong?

app.use(express.session({ store: new RedisStore({host: keys.redis.url, port: keys.redis.port, db: keys.redis.db, pass: keys.redis.pass}), secret: 'keyboard cat' }));

Error: Redis connection to redis://the.db.com:9313 failed - getaddrinfo ENOENT at RedisClient.on_error (/node_modules/connect-redis/node_modules/redis/index.js:136:24) at Socket. (/node_modules/connect-redis/node_modules/redis/index.js:70:14) at Socket.emit (events.js:67:17) at Array.0 (net.js:562:16) at EventEmitter._tickCallback (node.js:192:40)


Solution

  • The host field of the object passed into the RedisStore constructor function should specify a hostname or IP address and not a url. This field is passed directly into a redis.createClient call as the host parameter: http://visionmedia.github.com/connect-redis/