Skip to content

Instantly share code, notes, and snippets.

@slickplaid
Created February 16, 2012 17:56
Show Gist options
  • Select an option

  • Save slickplaid/1846735 to your computer and use it in GitHub Desktop.

Select an option

Save slickplaid/1846735 to your computer and use it in GitHub Desktop.
Redis and Node.js ECONNREFUSED
var Redis = require('redis');
module.exports.configureCache = function(port, host, password) {
if(typeof port !== 'undefined' && typeof host !== 'undefined') {
console.log('Production Redis: ', port, host); // Production Redis: 6397 10.xxx.xx.xxx
Redis.debug_mode = true;
cache = Redis.createClient(port, host, null);
} else {
cache = Redis.createClient();
}
if(password) {
cache.auth(password, function() {
cache.on('error', function(err) {
console.log('Cache Error (Redis): '+err);
});
cache.select(1);
module.exports.cache = cache;
});
} else {
cache.on('error', function(err) {
console.log('Cache Error (Redis): '+err);
});
cache.select(1);
module.exports.cache = cache;
}
}
Redis connection to 10.xxx.xx.xxx:6397 failed - connect ECONNREFUSED
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: Redis connection to 10.xxx.xx.xxx:6397 failed - connect ECONNREFUSED
at RedisClient.on_error (/home/<removed>/node_modules/redis/index.js:136:24)
at Socket.<anonymous> (/home/<removed>/node_modules/redis/index.js:70:14)
at Socket.emit (events.js:67:17)
at Array.0 (net.js:319:25)
at EventEmitter._tickCallback (node.js:192:40)
*@*:~/<removed>$ telnet 10.xxx.xx.xxx 6379
Trying 10.xxx.xx.xxx...
Connected to 10.xxx.xx.xxx.
Escape character is '^]'.
auth <removed>
+OK
get what
$-1
set what hello
+OK
get what
$5
hello
del what
:1
get what
$-1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment