Celeb Glow
general | March 18, 2026

mongodb Unable to create/open lock file

I installed mongodb:

sudo apt-get install mongodb

Tried to run it:

mongod

Runs into this error:

Mon Aug 21 20:46:44 [initandlisten] exception in initAndListen: 10309 Unable to create/open
lock file: /data/db/mongod.lock errno:13 Permission denied Is a mongod instance already running?, terminating

But the access rights must be fixed by now:

makan@blah:~$ls -hal /data/db/
total 8.0K
drwxr-xr-x 2 mongodb mongodb 4.0K Aug 21 19:56 .
drwxr-xr-x 3 mongodb mongodb 4.0K Aug 21 19:56 ..

and:

makan@blah:~$ls -hal /data/
drwxr-xr-x 2 mongodb mongodb 4.0K Aug 21 19:56 db

So why can't mongodb open/create the lock file?

4

1 Answer

From the question description it appears you are running mongod from your own account (user: makan).

Your invocation of mongod without specifying a configuration file or --dbpath would require this user to have read/write permissions for the default dbpath directory (/data/db). Since /data/db is only writable by user mongodb, a permission error is expected when mongod tries to write a file running with the permissions of makan:

lock file: /data/db/mongod.lock errno:13 Permission denied Is a mongod instance already running?, terminating

The usual way to start/stop mongod is using the service definition, which runs as the user and group mongodb via sudo service mongod start.

The service uses a configuration file (/etc/mongod.conf) and a data directory (/var/lib/mongodb) which should already have the correct permissions after installation.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy