I am running a Homestead virtual box. I installed mongodb recently and was able to type mongod and it would load as it should. Now though I get an error saying dbpath /data/db does not exist. The typical solution for that is to create /data/db and set the proper permissions. The problem is that I already have data, just not in that location. My site is able to connect to mongodb and access information...

I noticed my .0 and .ns file, which I assume are my data files, are actually saved in /var/lib/mongodb as well as a mongod.lock file

I tried setting my dbpath using "mongod --dbpath /var/lib/mongodb" to which I get an error:

exception in initAndListen: 10308 Unable to create/open lock file: /var/lib/mongodb/mongod.lock errno:13 Permission denied Is a mongod instance already running?, terminating

I've tried stopping mongod and then running the --dbpath command which produced the same error. I've also tried running in sudo


I decided to keep this up in case someone else runs into the same problem. The problem was that I was using:


when I should have been using:


Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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