connect failed mongo db on mac osx

you should read the documentation here: http://docs.mongodb.org/manual/tutorial/install-mongodb-on-os-x/ And follow the instructions.

In this case the [bunch of numbers] are the hostname/ip and port number that the binary mongo has tried to connect to. What it's telling you is that there is no mongod binary listening on the hostname and port that mongo is trying to connect to.

You will need to start mongod before you are able to connect to it with a mongo shell. The documentation above outlines this further.

If you use homebrew the mongodb binaries will automatically be put on your path which means you won't need to cd into another directory like mongo/bin.

Good luck.


Probably you run the mongodb first time. Based on the documentation you must follow a few steps and then you are ready to go.

First, create main db directory:

sudo mkdir -p /data/db

Make sure that you have a read and write permission on that directory:

sudo chown `id -u` /data/db

And to listen to default port, run:

mongod

Finally keep in mind that after the run "mongod" command do not close console tab. Open a new tab (Cmd + T) and run other commands on the new window. To close the mongod session simply hit the Ctrl + C on the previous tab.

Tags:

Macos

Mongodb