I first execute the command:
sudo service mongodb restart
I get the prompt:
stop: Unknown instance:
mongodb start/running, process 3175
Then,I execute the command:
mongo
I get the error:
MongoDB shell version: 2.4.6
connecting to: test
Tue Oct 8 19:48:08.961 Error: couldn't connect to server 127.0.0.1:27017 at src/mongo/shell/mongo.js:145
exception: connect failed
I don't know how I get this error.
These are some of the solutions: Ensure that your MongoDB instance is running: Compass must connect to a running MongoDB instance. Also check you have installed MongoDB and have a running mongod process. You should also check that the port where MongoDB is running matches the port you provide in the compass connect.
Then restart the server, and see if it connects. Means that NO mongod instance is running at the given host 127.0. 0.1 and port 27017. Yes the solution is to start mongod.
Execute the following command
sudo rm -rf /var/lib/mongodb/mongod.lock
then
sudo service mongodb restart
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