4

This is the error I get whenever I try to run mongo

MongoDB shell version: 2.2.2
connecting to: test
Wed Dec 12 15:51:57 Error: couldn't connect to server 127.0.0.1:27017 src/mongo/shell/mongo.js:91
exception: connect failed

Whenever I run mongod on shell I get this:

Wed Dec 12 15:53:04 [initandlisten] MongoDB starting : pid=763 port=27017 dbpath=/data/db/ 64-bit host=rachitpuri.one97.delhi.net
Wed Dec 12 15:53:04 [initandlisten] 
Wed Dec 12 15:53:04 [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
Wed Dec 12 15:53:04 [initandlisten] db version v2.2.2, pdfile version 4.5
Wed Dec 12 15:53:04 [initandlisten] git version: nogitversion
Wed Dec 12 15:53:04 [initandlisten] build info: Darwin tensix-slave.macports.org 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun  7 16:32:41 PDT 2011; root:xnu-1504.15.3~1/RELEASE_X86_64 x86_64 BOOST_LIB_VERSION=1_49
Wed Dec 12 15:53:04 [initandlisten] options: {}
Wed Dec 12 15:53:04 [initandlisten] journal dir=/data/db/journal
Wed Dec 12 15:53:04 [initandlisten] recover : no journal files present, no recovery needed
Wed Dec 12 15:53:04 [websvr] admin web console waiting for connections on port 28017
Wed Dec 12 15:53:04 [initandlisten] waiting for connections on port 27017

Some how I have to mongod.conf files is that a conflict in system at different locations and in none of them dbpath=/data/db

Leigh
  • 28,765
  • 10
  • 55
  • 103
Rachit
  • 59
  • 1
  • 3
  • Looks like a permission problem, check this [answer](http://stackoverflow.com/questions/12232166/mongodb-on-unbuntu-wont-start-as-a-service-nothing-in-the-log) for more details. – Eric Dec 12 '12 at 10:20
  • 1
    you start mongod first, right? then you try to start mongo and get this message? – Asya Kamsky Dec 12 '12 at 10:59

1 Answers1

4

There is two parts of mongoDB that are interacting here. The first part is mongod which is the server process itself. The second part is mongo which is the shell.

The shell will connect to the server process, and then allow you to issue the commands, run queries and all other operations normally associated with running MongoDB. Because of this you will need both mongod and mongo running at the same time.

You can do this several ways. The easiest is to open a terminal window (or a command prompt under Windows) and start the mongod process. Then in another terminal window, start the mongo process. If all of the defaults are being used this will result in the mongo process connecting to the mongod process and allowing you to interact with MongoDB.

The end of the log from mongod that you have shown indicates that it is ready to accept connections:

Wed Dec 12 15:53:04 [initandlisten] waiting for connections on port 27017

This means you can start a mongo process in another terminal window and connect to the server on port 27017. The mongod process will still need to be running, otherwise the mongo process will have nothing to connect to.

There is more information on starting mongod in the installation guides for your operating system.

You can find more information on using the shell here

Andre de Frere
  • 2,703
  • 16
  • 13