Probably because launchctll manages your mongod instance. If you want to start and close the mongod instance, first unload it:
launchctl unload -w ~/Library/LaunchAgents/org.mongodb.mongod.plist
Then run mongod manually:
mongod -f path/to/mongod.conf --fork
You can find your mongod.conf location from ~/Library/LaunchAgents/org.mongodb.mongod.plist .
After that, db.shutdownServer() will work fine.
Added February 22, 2014:
If you have mongodb installed via homebrew, homegrown does have a convenient brew services team. To show current current services:
brew services list
To start mongodb:
brew services start mongodb
To stop mongodb if it is already running:
brew services stop mongodb
Update
As edufinn noted in a comment, brew services now available as a user command and can be installed with the following command: brew tap gapple/services .
James Chen Dec 14 '11 at 5:12 2011-12-14 05:12
source share