I was having an issue on Mac OS X – this is probably because I installed it with
homebrew a few months back and forgot about these instructions.
$mongodb MongoDB shell version: 2.0.6 connecting to: test Sat Jun 16 09:11:43 exception: connect failed Error: couldn't connect to server 127.0.0.1 shell/mongo.js:84
I search for a solution but didn’t easily find one, so I ended up uninstalling it and reinstalling it, which then gave me the very valuable notes below about where config files and data paths are stored on OSX, and also let me know that I needed to start the service if I wanted to use it.
Here are those notes:
Already downloaded: /Users/me/Library/Caches/Homebrew/mongodb-2.0.6-x86_64.tgz
If this is your first install, automatically load on login with:
mkdir -p ~/Library/LaunchAgents cp /usr/local/Cellar/mongodb/2.0.6-x86_64/homebrew.mxcl.mongodb.plist ~/Library/LaunchAgents/ launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mongodb.plist
If this is an upgrade and you already have the homebrew.mxcl.mongodb.plist loaded:
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mongodb.plist cp /usr/local/Cellar/mongodb/2.0.6-x86_64/homebrew.mxcl.mongodb.plist ~/Library/LaunchAgents/ launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mongodb.plist
Or start it manually:
mongod run --config /usr/local/etc/mongod.conf
The launchctl plist above expects the config file to be at
/usr/local/Cellar/mongodb/2.0.6-x86_64: 18 files, 122M, built in 2 seconds
You might want to run
brew update and
brew upgrade to update / upgrade all of your homebrew packages, or
brew update and
brew upgrade mongodb to update mongodb to the latest version.
A few other notes if you’re using homebrew:
# updates the database of available software and what the latest # available version for each is. run this before running other brew commands. brew update # upgrades all homebrew packages on the system. can also be used to # just upgrade a specific package by specifying the package name brew upgrade # removes the specified package from your system brew remove # installs a specified package from your system brew install
More notes about the brew command can be found at https://github.com/mxcl/homebrew/wiki/The-brew-command