MongoError: failed to connect to server [localhost:27017] on first connect - mongodb

I have paid a membership and downloaded this project. After npm install and node app.js, it returns the following error:
Does anyone know what's wrong?
/Users/Thomas/Desktop/mean-stack-tutorial-01$ node app.js
/Users/Thomas/Desktop/mean-stack-tutorial-01/node_modules/mongodb/lib/server.js:265
process.nextTick(function() { throw err; })
^
MongoError: failed to connect to server [localhost:27017] on first connect
at Pool.<anonymous> (/Users/Thomas/Desktop/mean-stack-tutorial-01/node_modules/mongodb-core/lib/topologies/server.js:325:35)
at emitOne (events.js:96:13)
at Pool.emit (events.js:188:7)
at Connection.<anonymous> (/Users/Thomas/Desktop/mean-stack-tutorial-01/node_modules/mongodb-core/lib/connection/pool.js:270:12)
at Connection.g (events.js:292:16)
at emitTwo (events.js:106:13)
at Connection.emit (events.js:191:7)
at Socket.<anonymous> (/Users/Thomas/Desktop/mean-stack-tutorial-01/node_modules/mongodb-core/lib/connection/connection.js:173:49)
at Socket.g (events.js:292:16)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at emitErrorNT (net.js:1281:8)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickCallback (internal/process/next_tick.js:98:9)
Edit 1: Following the comments, I just installed mongo via brew, and did brew services start mongodb and then mongo:
/Users/Thomas$ mongo
MongoDB shell version v3.4.1
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.4.1
Server has startup warnings:
2017-01-12T19:53:01.868+0800 I CONTROL [initandlisten]
2017-01-12T19:53:01.869+0800 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2017-01-12T19:53:01.869+0800 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2017-01-12T19:53:01.869+0800 I CONTROL [initandlisten]
Then I did
/Users/Thomas$ mongod -httpinterface --dbpath /Users/Thomas/Desktop/MongoDB/db
2017-01-12T20:14:05.620+0800 I CONTROL [initandlisten] MongoDB starting : pid=47356 port=27017 dbpath=/Users/Thomas/Desktop/MongoDB/db 64-bit host=Pro.local
2017-01-12T20:14:05.621+0800 I CONTROL [initandlisten] db version v3.4.1
2017-01-12T20:14:05.621+0800 I CONTROL [initandlisten] git version: 5e103c4f5583e2566a45d740225dc250baacfbd7
2017-01-12T20:14:05.621+0800 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2j 26 Sep 2016
2017-01-12T20:14:05.621+0800 I CONTROL [initandlisten] allocator: system
2017-01-12T20:14:05.621+0800 I CONTROL [initandlisten] modules: none
2017-01-12T20:14:05.621+0800 I CONTROL [initandlisten] build environment:
2017-01-12T20:14:05.621+0800 I CONTROL [initandlisten] distarch: x86_64
2017-01-12T20:14:05.621+0800 I CONTROL [initandlisten] target_arch: x86_64
2017-01-12T20:14:05.621+0800 I CONTROL [initandlisten] options: { storage: { dbPath: "/Users/Thomas/Desktop/MongoDB/db" } }
2017-01-12T20:14:05.657+0800 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=3584M,session_max=20000,eviction=(threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),checkpoint=(wait=60,log_size=2GB),statistics_log=(wait=0),
2017-01-12T20:14:14.108+0800 I CONTROL [initandlisten]
2017-01-12T20:14:14.108+0800 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2017-01-12T20:14:14.108+0800 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2017-01-12T20:14:14.108+0800 I CONTROL [initandlisten]
2017-01-12T20:14:14.108+0800 I CONTROL [initandlisten]
2017-01-12T20:14:14.109+0800 I CONTROL [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
2017-01-12T20:14:15.390+0800 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory '/Users/Thomas/Desktop/MongoDB/db/diagnostic.data'
2017-01-12T20:14:16.303+0800 I INDEX [initandlisten] build index on: admin.system.version properties: { v: 2, key: { version: 1 }, name: "incompatible_with_version_32", ns: "admin.system.version" }
2017-01-12T20:14:16.304+0800 I INDEX [initandlisten] building index using bulk method; build may temporarily use up to 500 megabytes of RAM
2017-01-12T20:14:16.406+0800 I INDEX [initandlisten] build index done. scanned 0 total records. 0 secs
2017-01-12T20:14:16.407+0800 I COMMAND [initandlisten] setting featureCompatibilityVersion to 3.4
2017-01-12T20:14:16.407+0800 I NETWORK [thread1] waiting for connections on port 27017
Then in another terminal, I did node app.js, which hangs (and does not print anything). Then I does http://localhost:28017 in a browser, it seems to work:
However, how could I see the website?
Edit 2:
The normal process is
install mongo
brew services start mongodb in a terminal
mongo & (assume we use the default folder /data/db/)
npm start
see e.g., bin/www for the port number, then use localhost:the_port_number in a browser

Update 2020 Feb 24:
It would be wise to stay tuned with it. Here is the link for latest library instruction:
https://docs.mongodb.com/manual/administration/install-community/
You haven't started your monogo database. first install mongo install mongo as per your OS https://docs.mongodb.com/v3.0/tutorial/
then follow instructions mentioned on this site:
https://docs.mongodb.com/v3.0/tutorial/getting-started-with-the-mongo-shell/
cd .
mongod --dbpath "any directory path to start your database "
and then start your node server. It will work fine.
Hope this helps!!

First open another terminal an run command mongod to start your mongoDB
Then again start you node server npm start or if you have "nodemon" then using nodemon
I think now everything will be fine it will show
Mongoose connected to mongodb://localhost/your_database

I had the same issue but it worked fine after restarting the service
service mongod start

Related

Error: couldn't connect to server 127.0.0.1:27017 even though I am running mongod

MongoDB shell version v4.2.3
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
2020-05-02T19:00:36.477-0500 E QUERY [js] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused :
connect#src/mongo/shell/mongo.js:341:17
#(connect):2:6
2020-05-02T19:00:36.483-0500 F - [main] exception: connect failed
2020-05-02T19:00:36.483-0500 E - [main] exiting with code 1
That is the error that I am getting after running Mongo and this is the response that I get after running mongod
2020-05-02T19:00:34.303-0500 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2020-05-02T19:00:34.309-0500 I CONTROL [initandlisten] MongoDB starting : pid=3964 port=27017 dbpath=/data/db 64-bit host=Mateos-MBP.attlocal.net
2020-05-02T19:00:34.309-0500 I CONTROL [initandlisten] db version v4.2.3
2020-05-02T19:00:34.309-0500 I CONTROL [initandlisten] git version: 6874650b362138df74be53d366bbefc321ea32d4
2020-05-02T19:00:34.309-0500 I CONTROL [initandlisten] allocator: system
2020-05-02T19:00:34.309-0500 I CONTROL [initandlisten] modules: none
2020-05-02T19:00:34.309-0500 I CONTROL [initandlisten] build environment:
2020-05-02T19:00:34.309-0500 I CONTROL [initandlisten] distarch: x86_64
2020-05-02T19:00:34.309-0500 I CONTROL [initandlisten] target_arch: x86_64
2020-05-02T19:00:34.309-0500 I CONTROL [initandlisten] options: {}
2020-05-02T19:00:34.310-0500 I STORAGE [initandlisten] exception in initAndListen: NonExistentPath: Data directory /data/db not found., terminating
2020-05-02T19:00:34.310-0500 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2020-05-02T19:00:34.313-0500 I - [initandlisten] Stopping further Flow Control ticket acquisitions.
2020-05-02T19:00:34.313-0500 I CONTROL [initandlisten] now exiting
2020-05-02T19:00:34.313-0500 I CONTROL [initandlisten] shutting down with code:100
I have looked at multiple other questions and still can't seem to figure it out any help would be appreciated.
Create a directory /data/db and give permission to the MongoDB user so that MongoDB can access it. To create the directory:
sudo mkdir -p /data/db
To change owner:
sudo chown -R $USER /data/db
I followed this simple steps
Open your task manager if on windows
go to services -> go to MongoDB on services list provided
left click to highlight then down below click
->open services
on the list provided find MongoDB server
left click to highlight
click on the green play button to start the mongoDbServer
wait for a while
run your command again it will work
Open your task manager>services>MongoDB>"right-click and start the server"
It's obvious, that the MongoDB startup failed.
2020-05-02T19:00:34.310-0500 I STORAGE [initandlisten] exception in initAndListen: NonExistentPath: Data directory /data/db not found., terminating
That's why you can't connect it. Because it's never startup. You can try to fix the MongoDB startup issue, then try to log in through CMD to make sure it's ok.

Issue running MongoDB on mac 'Unable to lock the lock file'

I'm having trouble running MongoDB on my mac. MongoDB is the first database I've ever played with (I'm doing a tutorial) so I'm a bit lost.
I'm getting the following error in my terminal:
Joshuas-MacBook-Pro:~ joshua$ mongod
2018-07-25T14:11:36.709+0100 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2018-07-25T14:11:36.725+0100 I CONTROL [initandlisten] MongoDB starting : pid=10623 port=27017 dbpath=/data/db 64-bit host=Joshuas-MacBook-Pro.local
2018-07-25T14:11:36.725+0100 I CONTROL [initandlisten] db version v4.0.0
2018-07-25T14:11:36.725+0100 I CONTROL [initandlisten] git version: 3b07af3d4f471ae89e8186d33bbb1d5259597d51
2018-07-25T14:11:36.725+0100 I CONTROL [initandlisten] allocator: system
2018-07-25T14:11:36.725+0100 I CONTROL [initandlisten] modules: none
2018-07-25T14:11:36.725+0100 I CONTROL [initandlisten] build environment:
2018-07-25T14:11:36.725+0100 I CONTROL [initandlisten] distarch: x86_64
2018-07-25T14:11:36.725+0100 I CONTROL [initandlisten] target_arch: x86_64
2018-07-25T14:11:36.725+0100 I CONTROL [initandlisten] options: {}
2018-07-25T14:11:36.725+0100 I STORAGE [initandlisten] exception in initAndListen: DBPathInUse: Unable to lock the lock file: /data/db/mongod.lock (Resource temporarily unavailable). Another mongod instance is already running on the /data/db directory, terminating
2018-07-25T14:11:36.725+0100 I CONTROL [initandlisten] now exiting
2018-07-25T14:11:36.725+0100 I CONTROL [initandlisten] shutting down with code:100
Joshuas-MacBook-Pro:~ joshua$
Does anyone have an idea of what I can do to fix it? I haven't seen any posts with people getting the 'Unable to lock the lock file' issue.
Thank you for any help!
You have already mongod instance is running and using dbPath.
You don't need to start again.
Stop or kill all mongo instance first and then start again.
Upstart: sudo service mongodb stop
Sysvinit: sudo /etc/init.d/mongodb stop
Or on Mac OS X:
Find PID of mongod process using $ top
Kill the process by $ kill <PID> (Mongo docs for more information)

Rails Exception Mongo::Error::NoServerAvailable

I want to use MongoDB with my Rails app.
The error is not uncommon but none of the suggestions has worked for me.
I've installed mongodb using homebrew and followed the folowing the steps for same
brew update
brew install mongodb
sudo mkdir -p /data/db
sudo chmod 777 /data/db
brew tap homebrew/services
I use brew services start mongodb to start my mongodb server and get the following response
2018-02-08T12:27:59.072+0530 I CONTROL [initandlisten] MongoDB starting : pid=39164 port=27017 dbpath=/data/db 64-bit host=C168s-iMac.local
2018-02-08T12:27:59.072+0530 I CONTROL [initandlisten] db version v3.6.2
2018-02-08T12:27:59.072+0530 I CONTROL [initandlisten] git version: 489d177dbd0f0420a8ca04d39fd78d0a2c539420
2018-02-08T12:27:59.072+0530 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2n 7 Dec 2017
2018-02-08T12:27:59.072+0530 I CONTROL [initandlisten] allocator: system
2018-02-08T12:27:59.072+0530 I CONTROL [initandlisten] modules: none
2018-02-08T12:27:59.072+0530 I CONTROL [initandlisten] build environment:
2018-02-08T12:27:59.072+0530 I CONTROL [initandlisten] distarch: x86_64
2018-02-08T12:27:59.072+0530 I CONTROL [initandlisten] target_arch: x86_64
2018-02-08T12:27:59.072+0530 I CONTROL [initandlisten] options: {}
2018-02-08T12:27:59.089+0530 I - [initandlisten] Detected data files in /data/db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2018-02-08T12:27:59.089+0530 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=3584M,session_max=20000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),statistics_log=(wait=0),verbose=(recovery_progress),
2018-02-08T12:28:01.222+0530 I STORAGE [initandlisten] WiredTiger message [1518073081:222686][39164:0x7fffa9db0340], txn-recover: Main recovery loop: starting at 2/18944
2018-02-08T12:28:01.330+0530 I STORAGE [initandlisten] WiredTiger message [1518073081:330012][39164:0x7fffa9db0340], txn-recover: Recovering log 2 through 3
2018-02-08T12:28:01.442+0530 I STORAGE [initandlisten] WiredTiger message [1518073081:442109][39164:0x7fffa9db0340], txn-recover: Recovering log 3 through 3
2018-02-08T12:28:02.563+0530 I CONTROL [initandlisten]
2018-02-08T12:28:02.563+0530 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2018-02-08T12:28:02.563+0530 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2018-02-08T12:28:02.563+0530 I CONTROL [initandlisten]
2018-02-08T12:28:02.563+0530 I CONTROL [initandlisten] ** WARNING: This server is bound to localhost.
2018-02-08T12:28:02.563+0530 I CONTROL [initandlisten] ** Remote systems will be unable to connect to this server.
2018-02-08T12:28:02.563+0530 I CONTROL [initandlisten] ** Start the server with --bind_ip <address> to specify which IP
2018-02-08T12:28:02.563+0530 I CONTROL [initandlisten] ** addresses it should serve responses from, or with --bind_ip_all to
2018-02-08T12:28:02.563+0530 I CONTROL [initandlisten] ** bind to all interfaces. If this behavior is desired, start the
2018-02-08T12:28:02.563+0530 I CONTROL [initandlisten] ** server with --bind_ip 127.0.0.1 to disable this warning.
2018-02-08T12:28:02.563+0530 I CONTROL [initandlisten]
2018-02-08T12:28:02.563+0530 I CONTROL [initandlisten]
2018-02-08T12:28:02.563+0530 I CONTROL [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
2018-02-08T12:28:02.572+0530 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory '/data/db/diagnostic.data'
2018-02-08T12:28:02.572+0530 I NETWORK [initandlisten] waiting for connections on port 27017
2018-02-08T12:28:09.302+0530 I NETWORK [listener] connection accepted from 127.0.0.1:51073 #1 (1 connection now open)
2018-02-08T12:28:09.302+0530 I NETWORK [conn1] received client metadata from 127.0.0.1:51073 conn: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "3.6.2" }, os: { type: "Darwin", name: "Mac OS X", architecture: "x86_64", version: "17.2.0" } }
Along with this I also start mongo
cd /usr/local/bin
mongod
which starts as expected.
I created my rails app without the ActiveRecord and used mongiod gem. Next i created the config file using rails g mongoid:config and added Mongoid.load! './config/mongoid.yml' in application.rb file so the config file is loaded.
The content for mongoid.yml is
development:
clients:
default:
database: mongo_db_demo_development
hosts:
- localhost:27017
test:
clients:
default:
database: mongo_db_demo_test
hosts:
- localhost:27017
options:
read:
mode: :primary
max_pool_size: 1
I created my scaffold for Person and the model was created as expected using include Mongoid::Document. I went ahead and used the index of person as my root_path.
When i run the rails server, I get the following error
ActionView::Template::Error (No server is available matching preference: # using server_selection_timeout=30 and local_threshold=0.015):
I know its an exception by rails but cant seem to resolve it for hours now.
I referred this tutorial to get started. The weird thing is that I was successful to set up the app in accessing it and the next day it crashed with this error without any changes. I'm able to access the books's new page /books/new but cant seem to save it, hence making it clear that the app is unable to access the database.
I've since uninstalled mongodb twice wondering if the installation has some problem but cant seem to figure out whats wrong.
I understand there are many similar questions but none to resolve my issue. I don't understand what I'm missing and going wrong. Any help is appreciated.
Thanks
Update
I was somehow able to run another project that had active record and mongodb in it. Here is the same. I was successful in saving the data to the post model proving that the mongod and mongo are running and the setup is done correctly. Which means that I'm missing something in my app configuration but yet, I've no clue.

Unable to connect to mongo server

Im using mongoDb V 3.4 and trying to start the server but it says
C:\Users\gokul ram>mongo
MongoDB shell version v3.4.10
connecting to: mongodb://127.0.0.1:27017
2017-11-18T09:25:27.061+0530 W NETWORK [thread1] Failed to connect to 127.0.0.1:27017 after 5000ms milliseconds, giving up.
2017-11-18T09:25:27.062+0530 E QUERY [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :
connect#src/mongo/shell/mongo.js:237:13
#(connect):1:6
exception: connect failed
I also tried with --dbpath command, but it is waiting for connection for long time, still not getting connected
C:\Program Files\MongoDB\Server\3.4\bin>mongod --dbpath "C:/data/db"
2017-11-18T09:36:03.368+0530 I CONTROL [initandlisten] MongoDB starting : pid=4660 port=27017 dbpath=C:/data/db 64-bit host=GOK_RAM
2017-11-18T09:36:03.370+0530 I CONTROL [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R2
2017-11-18T09:36:03.370+0530 I CONTROL [initandlisten] db version v3.4.10
2017-11-18T09:36:03.371+0530 I CONTROL [initandlisten] git version: 078f28920cb24de0dd479b5ea6c66c644f6326e9
2017-11-18T09:36:03.371+0530 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1u-fips 22 Sep 2016
2017-11-18T09:36:03.371+0530 I CONTROL [initandlisten] allocator: tcmalloc
2017-11-18T09:36:03.371+0530 I CONTROL [initandlisten] modules: none
2017-11-18T09:36:03.371+0530 I CONTROL [initandlisten] build environment:
2017-11-18T09:36:03.371+0530 I CONTROL [initandlisten] distmod: 2008plus-ssl
2017-11-18T09:36:03.371+0530 I CONTROL [initandlisten] distarch: x86_64
2017-11-18T09:36:03.372+0530 I CONTROL [initandlisten] target_arch: x86_64
2017-11-18T09:36:03.372+0530 I CONTROL [initandlisten] options: { storage: { dbPath: "C:/data/db" } }
2017-11-18T09:36:03.375+0530 I - [initandlisten] Detected data files in C:/data/db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2017-11-18T09:36:03.376+0530 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=1509M,session_max=20000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),checkpoint=(wait=60,log_size=2GB),statistics_log=(wait=0),
2017-11-18T09:36:04.096+0530 I CONTROL [initandlisten]
2017-11-18T09:36:04.097+0530 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2017-11-18T09:36:04.097+0530 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2017-11-18T09:36:04.098+0530 I CONTROL [initandlisten]
2017-11-18T09:36:04.098+0530 I CONTROL [initandlisten] Hotfix KB2731284 or later update is not installed, will zero-out data files.
2017-11-18T09:36:04.098+0530 I CONTROL [initandlisten]
2017-11-18T09:36:05.880+0530 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory 'C:/data/db/diagnostic.data'
2017-11-18T09:36:05.882+0530 I NETWORK [thread1] waiting for connections on port 27017
Is that problem with the mongo db version or my configurations? Any faced the same issue please help me!! Thanks in advance
First: navigate to C:\Program Files\MongoDB\Server\3.4\bin\ and run mongod.exe this will start the server .
second : in a new cmd typein mongo
this might work
You first need to start the mongo server using 'mongod.exe' command and set 'data\db' as dbpath where the data will be stored. Make sure the folders are created before running the command.
adding C:\Program Files\MongoDB\Server\3.4\bin\ to your environment variable 'PATH' will be beneficial.
To run the server type the following command in cmd prompt:
mongod --dbpath = C:\data\db
The server should run with default settings at port 27017
To connect to the server, open another cmd prompt and execute the 'mongo.exe' command. This should work.
Else you can try specifying the port number "mongo --port 27017"
First
We Need to Start the mongo server with --dbpath command
Next open seperate command window,
Set path to mongo bin and use mongo.exe command
Then you can start accesing mongo server.

MongoDB Issues on Yosemite

I typed in two commands, mongo and mongod and get the following results. Not sure how to fix this
mahtabalam$ mongo
MongoDB shell version: 3.0.6
connecting to: test
2015-09-19T18:59:35.315-0400 W NETWORK Failed to connect to 127.0.0.1:27017, reason: errno:61 Connection refused
2015-09-19T18:59:35.316-0400 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
mahtabalam$ mongod
2015-09-19T19:00:47.133-0400 E NETWORK [initandlisten] Failed to unlink socket file /tmp/mongodb-27017.sock errno:13 Permission denied
2015-09-19T19:00:47.134-0400 I - [initandlisten] Fatal Assertion 28578
2015-09-19T19:00:47.134-0400 I - [initandlisten]
***aborting after fassert() failure
Update 1:
After trying sudo mongod --dbpath="Users/mahtabalam/Sites/mongo/data/db and then pressing ctrl + c on my macbook pro, and then re-entering mongod has yielded the following:
2015-09-19T21:54:49.819-0400 I JOURNAL [initandlisten] journal dir=/data/db/journal
2015-09-19T21:54:49.820-0400 I JOURNAL [initandlisten] recover : no journal files present, no recovery needed
2015-09-19T21:54:49.836-0400 I JOURNAL [durability] Durability thread started
2015-09-19T21:54:49.836-0400 I CONTROL [initandlisten] MongoDB starting : pid=28979 port=27017 dbpath=/data/db 64-bit host=Mahtabs-MacBook-Pro.local
2015-09-19T21:54:49.836-0400 I JOURNAL [journal writer] Journal writer thread started
2015-09-19T21:54:49.836-0400 I CONTROL [initandlisten]
2015-09-19T21:54:49.836-0400 I CONTROL [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
2015-09-19T21:54:49.837-0400 I CONTROL [initandlisten] db version v3.0.6
2015-09-19T21:54:49.837-0400 I CONTROL [initandlisten] git version: nogitversion
2015-09-19T21:54:49.837-0400 I CONTROL [initandlisten] build info: Darwin yosemitevm.local 14.5.0 Darwin Kernel Version 14.5.0: Wed Jul 29 02:26:53 PDT 2015; root:xnu-2782.40.9~1/RELEASE_X86_64 x86_64 BOOST_LIB_VERSION=1_49
2015-09-19T21:54:49.837-0400 I CONTROL [initandlisten] allocator: system
2015-09-19T21:54:49.837-0400 I CONTROL [initandlisten] options: {}
2015-09-19T21:54:49.850-0400 I NETWORK [initandlisten] waiting for connections on port 27017
mongod command starts the DB server & it expects an argument dbpath so the full command would be sudo mongod --dbath="dblocation/data/db" where /data/db is mandatory to start the server.
Whereas mongo opens a mongo db shell where you can execute your db statements