1

I have problem to run Mongodb on my OSX. I have installed with brew and when I'm trying to start Mongodb server and type mongo and then run it getting me error:

$ mongo
MongoDB shell version: 3.0.7
connecting to: test
2015-11-17T12:56:16.793+0100 W NETWORK  Failed to connect to 127.0.0.1:27017, reason: errno:61 Connection refused
2015-11-17T12:56:16.794+0100 E QUERY    Error: couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed
    at connect (src/mongo/shell/mongo.js:179:14)
    at (connect):1:6 at src/mongo/shell/mongo.js:179
exception: connect failed

Can you please give me some useful advices? Thanks in advance.

Kiknaio
  • 76
  • 2
  • 9
  • 1
    Here is my useful advice: https://docs.mongodb.org/manual/tutorial/install-mongodb-on-os-x/#install-mongodb-on-os-x – Markus W Mahlberg Nov 17 '15 at 12:13
  • 1
    Possible duplicate of [What is the correct way to start a mongod service on linux / OS X?](http://stackoverflow.com/questions/5596521/what-is-the-correct-way-to-start-a-mongod-service-on-linux-os-x) – Blakes Seven Nov 17 '15 at 12:27

1 Answers1

2

mongo is the client shell, it's not a server. You start a MongoDB server with the mongod command. For example:

mongod --dbpath ~/mongodb/data

You can also start mongod automatically when your OS starts up. You can find instructions here: https://stackoverflow.com/a/17061202/236660

After the server is started, you can use mongo to connect to the server.

Note that you can also run the mongo shell without connecting to any server:

mongo --nodb

Of course, you won't be able to do much with just the shell.

Community
  • 1
  • 1
Dmytro Shevchenko
  • 33,431
  • 6
  • 51
  • 67