Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I had mongdb installed and evrything was working fine. I wanted to delete the mongodb lock. By mistake the directory /var/lib/mongodb/ got deleted.

So, I uninstalled mongo db and installed again. But now i always keep getting this error:

Error: couldn't connect to server 127.0.0.1:27017 at src/mongo/shell/mongo.js:145
exception: connect fail

The error remains same even if I try to login from terminal or rockmongo or my application. I am using ubuntu12.04 and have latest version of mongo.

share|improve this question
    
Have you seen this => stackoverflow.com/questions/16120397/… –  Achu Nov 26 '13 at 6:00
    
Yes..but in my /var/lib/mongodb there is no mongodb.lock. –  Sankalp Mishra Nov 26 '13 at 6:01
    
The file could be in a different path or it could be named mongo.lock –  Achu Nov 26 '13 at 6:05
    
What you get when you run this /usr/local/mongodb/bin/mongod? –  Achu Nov 26 '13 at 6:11
    
I get bash: /usr/local/mongodb/bin/mongod: No such file or directory –  Sankalp Mishra Nov 26 '13 at 6:12

1 Answer 1

up vote 1 down vote accepted

You get the connect failure because the server is not running. Run this:

sudo service mongodb restart

If that does not succeed then you will need to examine the log files for the server to see what is stopping it from starting. You can find the log in /var/log/mongodb/mongod.log and if it is not an obvious cause, then please add the relevant snippet to your question and I'd be happy to take a look.

If I were to guess based on your description, I would suspect you did not set the correct permissions on /var/lib/mongodb - when you recreated it. It should look like this:

drwxr-xr-x 4 mongodb mongodb 4096 Nov 26 18:52 mongodb

If it has incorrect permissions, then you can fix it with the following command:

sudo chown -R mongodb:mongodb /var/lib/mongodb
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.