Mongod not starts - error, log: STORAGE [initandlisten] exception in initAndListen: DBPathInUse: Unable to lock loc file

Chapter 1, Lab: Creating First Application User

Not able start the mongod. Note that last time I started with the same config file, it worked fine (on 25th). Today, when I started mongod it aborted, and the log file has this message:

2019-11-28T10:50:47.732+0000 I STORAGE [initandlisten] exception in initAndListen: DBPathInUse: Unable to lock the locfile: /var/mongodb/db/mongod.lock (Resource temporarily unavailable). Another mongod instance is already running on the /var/mongodb/db directory, terminating

I verified the dbpath file permissions, and the configuration file content. I think there is no issue with those. I also checked other posts, I didn’t find similar issues.

What is it I need to do? Thanks.

Prasad.

The error message says Another mongod instance is already running on the /var/mongodb/db directory so one of 2 things.

  1. Another mongod instance is already running on the /var/mongodb/db directory. Probably the one you started on the 25th.

or

  1. The mongod instance you started on the 25th has crashed or has been killed leaving the directory with a lock file, as mentioned ***/var/mongodb/db/mongod.lock, to prevent multiple instances to run off the same directory.

If you are sure no instance is running from the directory you may remove the lock file.

Yes, I did a ps and found a mongod process from 26th.

ps -eaf | grep mongod
vagrant 3073 1 1 Nov26 ? 00:24:12 mongod --config config1.conf

I killed the process and was able to start the mongod normally.

Thanks for replying.

Prasad.

Thanks @steevej-1495.

Hi @Prasad_45636,

I’m glad your issue got resolved. If you have any other query then please feel free to get back to us.

Happy Learning :slight_smile:

Thanks,
Shubham Ranjan
Curriculum Support Engineer