Installing and Running MongoDB on OSX


If someone can provide some insights here I would GREATLY appreciate it.

I am new to MongoDB, and (relatively) new to the command line.

I had a express/node.js app running on MongoDB locally successfully, but upon restarting my computer, I attempted to restart the Mongo server and it began giving errors and wouldn't start. Since then, I have re-installed Mongo several times only to find the same error occurring. this is what I am receiving:

privee:mongodb-osx-x86_64-2.4.6 jonlinton$ ./bin/mongo
MongoDB shell version: 2.4.6
connecting to: test
Mon Aug 26 14:48:47.168 Error: couldn't connect to server at     src/mongo/shell/mongo.js:145
exception: connect failed

Am I missing a step? Should I be creating a config file? Some basic guidance would be really helpful. Thanks in advance for any insights.

9/22/2017 5:57:57 PM

Accepted Answer

Assuming you have created the data/db directory under bin after install.

  1. Start a terminal for your mongo server
  2. Go to <mongodb-install-directory>/bin directory
  3. Run the command


  4. Start a terminal for your mongo shell

  5. Go to <mongodb-install-directory>/bin directory
  6. Run the command (make sure you put the name of the database)

    ./mongo test

7/24/2016 11:11:37 PM

If you have installed mongodb through homebrew then you can simply start mongodb through

brew services start mongodb

Then access the shell by


You can shut down your db by

brew services stop mongodb

You can restart your db by

brew services restart mongodb

For more options

brew info mongodb

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow