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
most probably your mongo db service is not started.
For ubuntu : sudo service mongod start
For windows : go to services and start the MongoDB service
also install link for mondoDB service https://www.mongodb.com/download-center/community
I had this problem and i solved it thanks to this man's answer https://stackoverflow.com/a/47433551/7917608
just start the mongo server from terminal
Ubuntu -
sudo systemctl start mongod
I had below error:
Error: connect ECONNREFUSED 127.0.0.1:27017
In my case, this issue occurred since MongoDB is not installed at all.
The solution was to install MongoDB from below location:
https://www.mongodb.com/download-center/community
After installing the ECONNREFUSED
error did not appear again.
Hope that helps.
because you didn't start mongod process before you try starting mongo shell.
Start mongod server
mongod
Open another terminal window
Start mongo shell
mongo
If you are a windows user, right click on Start and open Windows Powershell(Run as administartor). Then type
mongod
That's it. Your database will surely get connected!
You probably need to continue running your DB process (by running mongod
) while running your node server.