brew update
brew install mongodb
ln -sfv /usr/local/opt/mongodb/*.plist ~/Library/LaunchAgents
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mongodb.plist


MongoDB shell version: 3.2.4
connecting to: test
2016-04-12T20:53:47.253+0100 W NETWORK  [thread1] Failed to connect to, reason: errno:61 Connection refused
2016-04-12T20:53:47.253+0100 E QUERY    [thread1] Error: couldn't connect to server, connection attempt failed :

exception: connect failed

As per Can't start mongodb by launchctl on OS X Yosemite (10.10.2) I also tried:

brew tap gapple/services
brew services start mongodb

But got the same problem. However if I just do


and then in another shell, it works fine:

MongoDB shell version: 3.2.4
connecting to: test

I try several times to solve this problem here in my machine, so I found the correct solution: here

Especial thanks to @gorjanz.


I had a similar issue and this helped me:

#!/usr/bin/env sh

# checks to see if running 
launchctl list | grep mongo

launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.mongodb.plist
launchctl remove homebrew.mxcl.mongodb

pkill -f mongod

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

brew uninstall mongodb

# double check existence
ls -al /usr/local/bin/mong*
ls -al ~/Library/LaunchAgents

rm -R /usr/local/var/mongodb

Also see my answer here: https://stackoverflow.com/questions/41913838/installed-docker-and-ran-a-container-with-mongodb-now-brews-mongodb-isnt-work/41943399#41943399

  • Would you follow this by installing from brew again in the standard way? – tdc Jan 31 '17 at 12:04
  • Yes, I should have written that too! – timhc22 Jan 31 '17 at 18:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.