Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7521869
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:21:16+00:00 2026-05-30T02:21:16+00:00

I have a node.js application using Express and Redis. My question is how do

  • 0

I have a node.js application using Express and Redis. My question is how do I catch and handle a Redis connection error. I have an app.error function in express which handles most application errors but since this error is an error that gets thrown in the redis library it becomes an uncaught exception and the whole app goes down.

Can I just define an on_error method on my redis client and that will do the trick? If so maybe some sample code? Should I somehow handle it in a node.js next tick error? I’m not sure I understand the next statement exactly so not sure what’s the best practice.

In the code below the catch block never gets hit even if there is a connection error

try
{ 
  feedClient = redis.createClient(feedPort, feedHost);
}
catch (error)
{
  console.log('cannnot start redis' + error);
}

Here’s the uncaught error

node.js:134
        throw e; // process.nextTick error, or 'error' event on first tick
        ^
Error: Redis connection to localhost:6379 failed - ECONNREFUSED, Connection refused
    at RedisClient.on_error (/node_modules/redis/index.js:136:24)
    at Socket. (/node_modules/redis/index.js:70:14)
    at Socket.emit (events.js:64:17)
    at Array. (net.js:830:27)
    at EventEmitter._tickCallback (node.js:126:26)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T02:21:18+00:00Added an answer on May 30, 2026 at 2:21 am

    Yes, you need to specify an error handler:

    feedClient = redis.createClient(feedPort, feedHost);
    feedClient.on("error", function(err) {
      console.error("Error connecting to redis", err);
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Node.js app using Express that stores data in a mongoDB (locally).
Tonight I decided I'd try to build a simple Node.js application using Express on
I have an application which extracts data from an XML file using XPath. If
I have a application which uses a JTree. For each node in the tree,
I start to look at Node.js. Also I'm using Express. And I have a
I have two content types (job_post and application) linked using the node reference +
I've implemented the chat application using node.js. The program open the connection with the
Suppose I have a CMS application written in Node.js which persists data on a
I am building an app on node.js using express, and node-mysql driver. There is
I have the following in my node server using Express (truncated to the important

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.