Explore Courses Blog Tutorials Interview Questions
0 votes
in Web Technology by (47.6k points)

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 an 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.

2 Answers

0 votes
by (106k points)

For installing and running MongoDB on OSX you can follow the below-mentioned steps if you have 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.

0 votes
by (108k points)

If you have installed mongodb with the help of homebrew then you can easily 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

Related questions

0 votes
1 answer
0 votes
1 answer
asked Oct 18, 2019 in Web Technology by Sammy (47.6k points)
0 votes
2 answers
0 votes
1 answer

Browse Categories