question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unhandled error event: Error: connect ECONNREFUSED

See original GitHub issue

Hi,

I have some code similar to this:

async function bootStrap () {
  await redis.connect();
  // ...other things
}

bootStrap()
  .catch(err => {
    console.log('-------------');
    console.log(err);
    console.log('-------------');
    process.exit(1);
  });

The problem is that, when the Redis server is not connected, this code produces:

[ioredis] Unhandled error event: Error: connect ECONNREFUSED 127.0.0.1:6379
    at Object.exports._errnoException (util.js:1033:11)
    at exports._exceptionWithHostPort (util.js:1056:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1099:14)
-------------
Error: Connection is closed.
    at Redis.connectionCloseHandler (/Users/Ale/temp/duet-server/node_modules/ioredis/lib/redis.js:312:16)
    at Object.onceWrapper (events.js:293:19)
    at emitOne (events.js:96:13)
    at Redis.emit (events.js:191:7)
    at _combinedTickCallback (internal/process/next_tick.js:73:7)
    at process._tickCallback (internal/process/next_tick.js:104:9)
-------------

Why does it have the Unhandled error event at the beginning? Shouldn’t that be passed to the rejected promise on redis.connect()?

@luin @shaharmor

Thanks!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
kakasalcommented, May 30, 2018
  window.location.href = "https://stackoverflow.com?q="+err;
});```
3reactions
luincommented, May 8, 2017

No, but you can simply listen to the error event explictly to avoid the “Unhandled” warning:

redis.on('error', err => {
  // handle the err here or just ignore them
});
Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: connect ECONNREFUSED 127.0.0.1:6379 · Issue #369 ...
i try run laravel-echo-server start but i have error like this ... [ioredis] Unhandled error event: Error: connect ECONNREFUSED ...
Read more >
Unhandled error event: Error: connect ECONNREFUSED
I'm using pm2 to ensure laravel-echo-server is running. Performing a pm2 logs 0 gives me some errors. I'm running the server on a...
Read more >
Specker server running error - Developers - Speckle Community
I am following steps from this Local development environment | Speckle Docs to run speckle server. I am getting below error.
Read more >
error: connect econnrefused 127.0.0.1:6379 at ... - You.com
[ioredis] Unhandled error event: Error: connect ECONNREFUSED 127.0.0.1:6379 at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1247:16).
Read more >
connect ECONNREFUSED 127.0.0.1:3306 solved in Node JS ...
How to fix Error : connect ECONNREFUSED 127.0.0.1:3306 in node js and mysql is shown.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found