Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Homebrew mongodb connection failed - Mac OSX Sierra 10.12.6

I've installed mongodb with brew on my Mac OSX Sierra 10.12.6:

brew install mongodb

I get no errors when running:

brew services start mongodb

but when i try to run:

mongo

I get the following error:

MongoDB shell version v3.6.2
connecting to: mongodb://127.0.0.1:27017
2018-02-05T14:55:25.952-0500 W NETWORK  [thread1] Failed to connect to 127.0.0.1:27017, in(checking socket for error after poll), reason: Connection refused
2018-02-05T14:55:25.952-0500 E QUERY    [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :
connect@src/mongo/shell/mongo.js:251:13
@(connect):1:6
exception: connect failed

I've removed the .plist files, made sure that /data/db is there and all necessary permissions are on it. I can start mongodb without a problem and everything runs but I cannot get it to run with brew services start mongodb

Any ideas why?

like image 604
Nik Avatar asked Feb 05 '18 20:02

Nik


People also ask

How do I manually run MongoDB on a Mac?

Go to the MongoDB website's download section and download the correct version of MongoDB. Run the Mongo daemon, in one terminal window run ~/mongodb/bin/mongod . This will start the Mongo server. Run the Mongo shell, with the Mongo daemon running in one terminal, type ~/mongodb/bin/mongo in another terminal window.


1 Answers

If you don't need to keep your current data:

brew services stop mongodb

brew uninstall mongodb

rm -rf /usr/local/var/mongodb/

rm -rf ~/Library/LaunchAgents/homebrew.mxcl.mongodb.plist

rm -rf /usr/local/etc/mongod.conf

brew install mongodb

brew services start mongodb

should upgrade to the newest version and start it.

like image 151
gorjanz Avatar answered Oct 23 '22 19:10

gorjanz