Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error in mongo start

Tags:

mongodb

i am using mongo 3.0.2 version suddenly, i have got a problem in mongodb. Till yesterday mongodb is running fine. but today when i start mongo then it gives the following error.

2015-04-29T10:57:47.732+0530 W NETWORK  Failed to connect to  127.0.0.1:27017, reason: errno:111 Connection refused
2015-04-29T10:57:47.733+0530 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

i have checked on internet. deleted the mongo lock file. but didn't resolve the problem yet.

when i check the service is show waiting and after start it doen't start as

 service mongod status
 mongod stop/waiting
 sudo service mongod start
 mongod start/running, process 2520
 service mongod status
 mongod stop/waiting

and anyone help to solve it out and explain why this problem occur.

like image 560
Sourbh Gupta Avatar asked Apr 29 '15 05:04

Sourbh Gupta


People also ask

Why MongoDB server is not starting?

We found that the reason for this error was the dbpath variable in /etc/mongodb. conf. Previously, the default value for dbpath was /data/db. The upstart job mongodb(which comes with mongodb-10gen package) invokes the mongod with –config /etc/mongodb.

How do I start MongoDB in terminal?

To open up the MongoDB shell, run the mongo command from your server prompt. By default, the mongo command opens a shell connected to a locally-installed MongoDB instance running on port 27017 . Try running the mongo command with no additional parameters: mongo.

Why is my MongoDB file not showing up on my System?

On your system, if you have used MongoDB in the past it must have been with a different dbPath or you have since deleted that path. I suggest you either specify a different path or create the /data/db folder for MongoDB to store its data.

How to start MongoDB server in Windows using Mongo daemon?

Assuming that you installed MongoDB Server with default options, especially the installation folder as C:\Program Files\MongoDB\Server\4.0 . Inside this folder, you have the bin directory containing mongod.exe. To start MongoDB Server in Windows, start Mongo Daemon (mongod.exe) using the following command:

Why does mongod start with no dbpath parameter?

If you start mongod with no dbPath parameter it will default to /data/db. On your system, if you have used MongoDB in the past it must have been with a different dbPath or you have since deleted that path. I suggest you either specify a different path or create the /data/db folder for MongoDB to store its data.

How do I check if Mongo server is running?

From the messages logged to the console, you can observe that: Mongo Server is started as a process with process id (pid): 11716. Mongo Server is listening at the port number: 27107. You can see at the end of logs [initandlisten] waiting for connections on port 27017. Mongo Server is using the database present at the location C:\data\db\.


4 Answers

I had the same issue and I managed to start mongod following those steps

1) mkdir data

2) cd data

3) mongod -dbpath .

like image 135
svassr Avatar answered Oct 22 '22 00:10

svassr


Use this command, it works fine:

sudo mongod --config /etc/mongod.conf --fork
like image 35
Vishnu Gupta Avatar answered Oct 21 '22 22:10

Vishnu Gupta


Try using sudo mongo to connect

like image 37
Diego Maehler Avatar answered Oct 22 '22 00:10

Diego Maehler


Please make sure if port 27017 is already opened and didn't used by any application. You can check it with netstat command

like image 32
Cak Khoiron Avatar answered Oct 22 '22 00:10

Cak Khoiron