• Register
Welcome to Kodlogs, programming questions and answer website.
0 votes

Problem :

When I was trying to run the Mongod in terminal I got below message :

2020-01-14T17:33:04.554+0700 I STORAGE  [initandlisten] exception in initAndListen: 29 Data directory /data/db not found., terminating
2020-01-14T17:33:04.554+0700 I CONTROL  [initandlisten] dbexit:  rc: 100

And after running mongo command I got below message :

MongoDB shell version: 3.0.3
connecting to: test
2020-01-14T17:34:26.679+0700 W NETWORK  Failed to connect to, reason: errno:111 Connection refused
2020-01-14T17:34:26.681+0700 E QUERY    Error: couldn't connect to server (, 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

I am using the Ubuntu 14.04 LTS 64 bit. How can I fix this issue?

by (7.5k points)  

1 Answer

0 votes

Solution :

The MongoDB needs a data directory to store data. The Default path is /data/db

When you start the MongoDB engine, it tries to search above directory which is missing in your case. So solution is to create this directory and assign the rwx permission to your user.

If you want to change your path of the data directory then you must specify it while starting the mongod server as below,

mongod --dbpath /data/<path> --port <port no> 

This will help you in starting your mongod server with your custom path and the port number.

by (34.3k points)