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 >
Hey, thanks! This was very helpful to me, as I had the same problem on my mac. Maybe you could mention, that the "/data/db" folder has to be placed in the root-directory of the mac even if the "/" at the beginning should determine that. (I placed mine in my project folder at first, it didn't work well - the only logical conclusion was the root-dir.. neverthless..)
ReplyDeleteI have the same problem, thank you very much!
DeleteThis comment has been removed by the author.
ReplyDeleteExcellent!
ReplyDeleteI encountered the same problem, 'sudo mongod' solved this problem, Thank you!
ReplyDeleteThis field involves the use of Machine Learning that has enabled industries to create higher quality merchandise that are customized for each consumer. data science course syllabus
ReplyDelete