CelinVeronicca CelinVeronicca - 6 months ago 35x
PHP Question

Mongodb:Failed to connect

I am new to MongoDB.I installed mongodb and used with Laravel framework.Its had been worked for a long time without any issues.But currently while i try to acess my website it shows:

Failed to connect to: localhost:27017: Connection refused

when i try to acces mongodb via command line,it shows:

warning: Failed to connect to, reason: errno:111 Connection refused
Error: couldn't connect to server (, connection attempt failed at src/mongo/shell/mongo.js:146 exception: connect failed

when i try to access it via rock tool,it shows:

Unable to connect MongoDB, please check your configurations. MongoDB said:Failed to connect to: Connection refused.

what i will do? I can't figure what's wrong from my part since its working after the past months.I do nothing since the last days.Thanks in advance..


After a short break, I had found the solution. The origin of that issue is the unexpected shutdown of the system.So i run the below code in command prompt:

sudo rm /var/lib/mongodb/mongod.lock
mongod --repair
sudo service mongodb start

then after the above code run, its working fine :)