• Register
0 votes
2.3k views

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 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

6 5 3
7,540 points

Please log in or register to answer this question.

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 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.

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;

mogo

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

 

11 5 2
3,890 points

Related questions

0 votes
1 answer 8 views
8 views
Problem: How I can deal with this isssue: Pymongo.errors.serverselectiontimeouterror: localhost:27017: [errno 61] connection refused
asked Mar 13 Wafa Abu Yousef 6.1k points
0 votes
1 answer 30 views
30 views
Problem: I am trying to write a program for file transfer using sockets. The server end of the code is running fine. However, in the client side I get the following error Traceback (most recent call last): File "client.py", line 54, in <module> uploadFiles( ... usr/lib/python2.7/socket.py", line 224, in meth return getattr(self._sock,name)(*args) socket.error: [Errno 111] Connection refused
asked Jan 27 Mashhoodch 13k points
2 votes
1 answer 572 views
572 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, 2020 stewart 4k points
0 votes
1 answer 27 views
27 views
Problem: error: the `brew link` step did not complete successfully.
asked Feb 23 Dan phillip 4.8k points
1 vote
1 answer 26 views
26 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, 2020 morrisBson 3.2k points
0 votes
1 answer 395 views
395 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, 2020 mphil 2.3k points
0 votes
1 answer 14 views
14 views
Problem: How to I Solve this: socket.error: [errno 61] connection refused HELP! I need help understanding this: socket.error: [errno 61] connection refused Can someone please help solve this, I am new in python(). Someone have idea to solve this thanks!
asked Mar 6 Mashhoodch 13k points
0 votes
2 answers 61 views
61 views
Problem: Ive seen similar questions but they I couldn't fix this error. Me and my friend are making a chat program but we keep getting the error ConnectionRefusedError: [Errno 61] Connection refused We are on different networks by the way. Here is my code for the server import ... host = '' port = 9999 s = socket.socket() except socket.error as msg: print("Socket creation error" + str(msg))
asked Feb 13 Mashhoodch 13k points
0 votes
1 answer 2 views
2 views
Problem: Please help me to solve it... data directory /data/db not found., terminating
asked Mar 31 Ifra 24.4k points
0 votes
1 answer 6 views
6 views
Problem: how to Solve this: flask pymongo HELP! I need help understanding this: flask pymongo Can someone please help solve this, I am new in python(). Someone have idea to solve this thanks!
asked Mar 13 Mashhoodch 13k points