1

I'm trying to use Keyv, following this tutorial: https://discordjs.guide/keyv/#command-handler and I'm using the command handler code as well.

In my index.js, I run something like this: (with the appropriate imports for Keyv of course)

const Keyv = require('keyv');
const mykeyv = new Keyv('redis://user:pass@localhost:6379');
client.on('message', message =>{
    ...//skipping some command handler stuff 
    command.execute(message, args, mykeyv)
})

And then when I run this, I initially get the correct and expected client.on('ready') messages, but then a few seconds after the following error pops up:

events.js:292
      throw er; // Unhandled 'error' event
      ^

Error: connect ECONNREFUSED 127.0.0.1:6379
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1141:16)
Emitted 'error' event on Keyv instance at:
    at KeyvRedis.<anonymous> (C:\Users\Meroper80\Documents\GitHub\DndBot\Node-Js-Discord-Bot\node_modules\keyv\src\index.js:43:44)
    at KeyvRedis.emit (events.js:315:20)
    at Redis.<anonymous> (C:\Users\Meroper80\Documents\GitHub\DndBot\Node-Js-Discord-Bot\node_modules\@keyv\redis\src\index.js:17:38)
    at Redis.emit (events.js:315:20)
    at Redis.silentEmit (C:\Users\Meroper80\Documents\GitHub\DndBot\Node-Js-Discord-Bot\node_modules\ioredis\built\redis\index.js:499:26)
    at Socket.<anonymous> (C:\Users\Meroper80\Documents\GitHub\DndBot\Node-Js-Discord-Bot\node_modules\ioredis\built\redis\event_handler.js:186:14)
    at Object.onceWrapper (events.js:422:26)
    at Socket.emit (events.js:315:20)
    at emitErrorNT (internal/streams/destroy.js:92:8)
    at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
    at processTicksAndRejections (internal/process/task_queues.js:84:21) {
  errno: 'ECONNREFUSED',
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 6379
}

I'm not sure what this error is about, can someone help me?

M80
  • 191
  • 1
  • 14
  • 1
    This error indicates that your computer is refusing to establish a connection from port 6379. Is Redis running? – D. Pardal Jul 03 '20 at 20:22
  • @D.Pardal how do I check if redis is running? – M80 Jul 03 '20 at 20:28
  • If you ran it, then it's running. – D. Pardal Jul 03 '20 at 20:38
  • @D.Pardal Sorry if I'm not quite understanding what you mean, but when I say I ran it, I'm just running it by doing `>node index.js` on terminal. And I don't `require('redis')` anywhere in my code. I installed `npm install --save @keyv/redis`, and did `const Keyv = require('keyv')`, then ran the code above. I hope this helps. – M80 Jul 03 '20 at 23:10
  • Redis is a separate program. keyv just connects to it. – D. Pardal Jul 04 '20 at 12:24

0 Answers0