• Register
0 votes

Problem :

I am new to Mongodb and I have recently installed mongodb-2.6.0 with Homebrew. After successful installation, I just tried to connect using the mongo command but I am receiving the below errors which are not allowing me to connect:

Failed to connect to, reason: errno:61 Connection refused

 Error: couldn't connect to server (, connection attempt failed at src/mongo/shell/mongo.js:146

 exception: connect failed

6 5 3
7,540 points

2 Answers

0 votes

Solution :

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 update

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, reason: errno:61 Connection refused

Error: couldn't connect to server (, 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.

9 7 4
38,600 points
0 votes

This error can happen when the MongoDB service is not running on the mac while you involved in full-stack Django development and developing an application using MongoDB as the database backend. When the user tries to access the mongo shell by using the mongo command but got an error;

“Cannot connect to MongoDB error:61 connection refused.”

 This error can be solved in many ways;

Solution 1:

To solve your issue, you have to follow the instructions which are given to you by brew after your “brew install MongoDB”.

To launched start the MongoDB at login;

ln –sfv /usr/local/opt/mongodb/*.plist ~/Library/LaunchAgents

Then load the MongoDB again by using the command;

launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mongodb.plist

If you don’t need to launchtl, you can just run the following command;

mongod –config /usr/local/etc/mongod.conf

Solution 2:

Install the MongoDB by using the brew install command, if you already have MongoDB then you don’t need to follow this step;

brew update

brew install mongodb

Run the MongoDB Daemon by using the command;

mkdir –p /data/db

sudo mongod

Now run the mongo shell interface by using the command;


In this sequence, you can be able to run the mongo command without any error.


11 5 1
3,890 points

Related questions

2 votes
1 answer 272 views
Problem : I am very new to Mongodb, I am facing below error if I try to run the Mongodb. I had installed it with the help of Homebrew. Stewarts-MacBook-Pro:~ stewart$ mongod 2020-05-05T15:31:15.911+0700 I CONTROL  [initandlisten] MongoDB starting : pid ... +0700 I CONTROL  [initandlisten] shutting down with code:48 Stewarts -MacBook-Pro:~ stewart $ Kindly help me in resolving above Mongodb error.
asked May 6 stewart 4k points
1 vote
1 answer 22 views
Problem : Recently I have started learning Homebrew. Now if I try to run Homebrews brew doctor command on my Mac OS X 10.9.2 I have started receiving the below listed warning message: Warning: Python is installed at /Library/Frameworks/Python.framework Homebrew only ... /usr/local/bin/python. But still if I rerun the brew doctor command I am still facing the same warning message listed above.
asked Apr 4 morrisBson 3.2k points
0 votes
1 answer 300 views
Problem : Currently I am learning Homebrew (Mojave). Recently I tried to install the node using Homebrew (Mojave) but after sometime my Php stopped working and now if I try to run the command php -v I face below error: php -v dyld: Library not loaded: /usr/local ... from: /usr/local/bin/php Reason: image not found I have also tried to uninstall my both node and icu4c but my problem still persists
asked Feb 20 mphil 2.3k points
0 votes
2 answers 351 views
Problem : In the MacOS Mojave terminal I am trying to install a python package with pip. At the end of it says as follows : You are using pip version 10.0.1, however version 18.1 is available. You should consider upgrading via the 'pip install --upgrade pip' command. Here ... to do.Also I just realized that it says Python 2.7 in the error message but I have python 3 and want to use only python 3.
asked Dec 10, 2019 alecxe 7.5k points