Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot connect to mongodb errno:61 Connection refused

I recently installed mongodb-2.6.0 with Homebrew. After successfully installed, I tried to connect using the mongo command. I am receiving the following errors which do not allow 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 
like image 966
Michael Avatar asked May 01 '14 23:05

Michael


People also ask

Why is my MongoDB not connecting?

These are some of the solutions: Ensure that your MongoDB instance is running: Compass must connect to a running MongoDB instance. Also check you have installed MongoDB and have a running mongod process. You should also check that the port where MongoDB is running matches the port you provide in the compass connect.

Why I Cannot connect to MongoDB Atlas?

Check that you are using the correct username and password for your database user, and that you are connecting to the correct database deployment. Check that you are specifying the correct authSource database in your connection string.


1 Answers

It can happen when the mongodb service is not running on the mac. To start it, I tried

brew services start mongodb 

and it worked.

Edit: According to the discussion on this PR on homebrew: https://github.com/Homebrew/homebrew/issues/30628

brew services is deprecated, I looked around on SO and found these answers now answer the question: What is the correct way to start a mongod service on linux / OS X?

like image 64
Hrishi Avatar answered Oct 07 '22 00:10

Hrishi