close

[Fixed] node.js Error: connect ECONNREFUSED; response from server

Today We are Going To Solve node.js Error: connect ECONNREFUSED; response from server in javascript. Here we will Discuss All Possible Solutions and How this error Occurs So let’s get started with this Article.

How to Fix node.js Error: connect ECONNREFUSED; response from server Error?

  1. How to Fix node.js Error: connect ECONNREFUSED; response from server Error?

    To Fix node.js Error: connect ECONNREFUSED; response from server Error just Use this command. To take a place to attach the debugger and to keep your server running just follow the below commands. It will help you to solve your error. process.on('uncaughtException', function (err) { console.log(err); });
    This will help you to solve your error.

  2. node.js Error: connect ECONNREFUSED; response from server

    To Fix node.js Error: connect ECONNREFUSED; response from server Error just check the config and env. You have to just check the config and env that the server is running on. And try this command:
    heroku config:set NODE_ENV=production

Solution 1 : Use this command

To take a place to attach the debugger and to keep your server running just follow the below commands. It will help you to solve your error.

process.on('uncaughtException', function (err) {
    console.log(err);
}); 

This will help you to solve your error.

Solution 2 : check the config and env

You have to just check the config and env that the server is running on. And try this command:

heroku config:set NODE_ENV=production 

Solution 3 : start the mongodb

To solve this error just start the mongodb server with the command mongod 

mongoose.connect("mongodb://localhost:27017/demoDb");

This error occurs due to the database connection. If you didn’t start the database yet then it cause this error. You can try the above solution which will solve your error. Thank you!

Solution 4 : run mongodb

This method is for those who are using Mongo-Express-AngularJS-Node stack, If you are on MEAN Then just run mongod first. Because by using this you can get rid of this error.

Conclusion

So these were all possible solutions to this error. I hope your error has been solved by this article. In the comments, tell us which solution worked? If you liked our article, please share it on your social media and comment on your suggestions. Thank you.

Also Read This Solutions

Leave a Comment