LoginSignup

MongoError: connect ECONNREFUSED 127.0.0.1:27017

Asked 4 months agoAnswer 1Votes 0

0

195

I'm using NodeJS wih MongoDB using mongodb package. When I run mongod command it works fine and gives "waiting for connection on port 27017". So, mongod seems to be working. But MongoClient does not work and gives error when I run node index.js command-

MongoError: failed to connect to server [localhost:27017] on first connect [MongoError: connect ECONNREFUSED 127.0.0.1:27017]

MongoError: connect ECONNREFUSED 127.0.0.1:27017


1 Answers

0

I would suggest you to add allow connections from all IP addresses in your MongoDB atlas dashboard security settings.




Your Answer