I was involved in full stack Django development and while developing an application using Mongodb as database backend, I also encountered below error after installing Mongodb on my mac. so first, I installed Mongodb by using brew install command as follows:
brew install mongodb
After installing the Mongodb on my Mac, I tried to just access the mongo shell by using mongo command, but I got following error "Cannot connect to mongodb errno:61 Connection refused error" . Following is the full trace:
MongoDB shell version: 2.6.6
connecting to: test
warning: Failed to connect to 127.0.0.1:27017, reason: errno:61 Connection refused
Error: couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed at src/mongo/shell/mongo.js:146
exception: connect failed
So after receiving the error I searched for correct ways to start Mongodb on Mac OS. I tried many ways but the one which worked for me is as below:
In your shell write sudo mongod to start it as below:
$ mkdir -p /data/db
$ sudo mongod
This helped me in starting my Mongodb. Next I simply opened another shell instance and wrote the required mongo command and it worked without giving error Error Cannot connect to mongodb errno:61 Connection refused!
So my MongoDB starting Problem Solved.