Recently, while involved in full stack Django development and developing an application using Mongodb as database backend, I encountered following error after installing Mongodb on my mac.
Ok first, I installed Mongodb by using brew install command:
After installing Mongodb, I tried to access the mongo shell by using mongo command, but I got "Cannot connect to mongodb errno:61 Connection refused error" . Here is the full trace:
I searched for correct ways to start Mongodb on Mac OS. I tried several solutions but the one which worked for me is as follows: In the shell write sudo mongod to start it.
This started my Mongodb. Next I opened another shell instance (new shell window) and wrote mongo command and it worked without Error Cannot connect to mongodb errno:61 Connection refused! MongoDB starting Problem Solved.
brew update brew install mongodb
After installing Mongodb, I tried to access the mongo shell by using mongo command, but I got "Cannot connect to mongodb errno:61 Connection refused error" . Here is the full trace:
alis-air:~ aliraza$ mongo MongoDB shell version: 2.6.6 connecting to: test 2015-02-24T17:51:36.067+0500 warning: Failed to connect to 127.0.0.1:27017, reason: errno:61 Connection refused 2015-02-24T17:51:36.069+0500 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
I searched for correct ways to start Mongodb on Mac OS. I tried several solutions but the one which worked for me is as follows: In the shell write sudo mongod to start it.
$ mkdir -p /data/db $ sudo mongod
This started my Mongodb. Next I opened another shell instance (new shell window) and wrote mongo command and it worked without Error Cannot connect to mongodb errno:61 Connection refused! MongoDB starting Problem Solved.
$ mongo MongoDB shell version: 2.6.6 connecting to: test Server has startup warnings: 2015-02-24T18:20:51.384+0500 [initandlisten] 2015-02-24T18:20:51.384+0500 [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000 >