Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MongoDB won't connect to 127.0.0.1 on Mac OS X

I have a Mac running 10.8.2 and just installed mongodb running the brew install mongodb command. Everything seemed to be installed correctly. However when I run mongo to enter the shell I get the following error:

Alexander-Burgos-Collazos-MacBook:~ Alexander$ mongo
MongoDB shell version: 2.2.3
connecting to: test
Wed Feb  6 19:44:59 Error: couldn't connect to server 127.0.0.1:27017 src/mongo/shell/mongo.js:91
exception: connect failed

I followed some threads around here but never got a clear and concise answer as to how to fix it. I entered mongod in the command terminal and it returned:

all output going to: /usr/local/var/log/mongodb/mongo.log

From there on everything I input does not return anything. I am confused as to how this really works.

like image 200
Alex Burgos Avatar asked Dec 06 '22 09:12

Alex Burgos


2 Answers

May be mongod not started.

For start manually use command:

/usr/local/opt/mongodb/mongod run --config /usr/local/etc/mongod.conf

But brew has a lanchctl plist. You can run this command and mongodb launch at login:

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

More about brew version mongodb:

brew info mongodb

More about mongod you can read in manual.

like image 51
Vladimir Korshunov Avatar answered Dec 25 '22 03:12

Vladimir Korshunov


Latest versions of Brew supports

brew services start mongodb

like image 27
ravi404 Avatar answered Dec 25 '22 02:12

ravi404