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.
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.
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.
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.
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:
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.
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\.
I had the same issue and I managed to start mongod following those steps
1) mkdir data
2) cd data
3) mongod -dbpath .
Use this command, it works fine:
sudo mongod --config /etc/mongod.conf --fork
Try using sudo mongo
to connect
Please make sure if port 27017 is already opened and didn't used by any application. You can check it with netstat
command
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With