4
votes

2017-06-12T13:06:18.407+0300 I STORAGE [initandlisten] exception in initAndListen: 98 Unable to lock file: /data/db/mongod.lock Resource temporarily unavailable. Is a mongod instance already running?, terminating
2017-06-12T13:06:18.407+0300 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2017-06-12T13:06:18.407+0300 I NETWORK [initandlisten] shutdown: going to flush diaglog...
2017-06-12T13:06:18.407+0300 I CONTROL [initandlisten] now exiting
2017-06-12T13:06:18.407+0300 I CONTROL [initandlisten] shutting down with code:100

1
Not really enough information here. But also. This really should be asked on dba,stackexchange.com which is for questions and answers relating to database administration and configuration. StackOverflow is for :"programming" based questions, of which this is not. Please move your post to the appropriate site instead of posting here. But please add some more information when posting there. - Neil Lunn
Can you check if an instance of mongod is already running? On *nix systems, you can run ps -eaf | grep mongod to find out the process id of running mongod. Also, check whether the /data/db directory is already created. If created, check the permissions whether you can write/read data. - harshavmb
go to /data/db/ folder delete mongod.lock file it will solve your problem. this problem occurs becoz you did't shut down mongodb properly - Dexter
thank you @NeilLunn I will try that - Zainab Hammami
yes I have the /data/db directory but how can I check the permissions? sorry I am totally new for that @harshavmb - Zainab Hammami

1 Answers

23
votes

The error clearly says

exception in initAndListen: 98 Unable to lock file: /data/db/mongod.lock Resource temporarily unavailable. Is a mongod instance already running?, terminating

An instance of mongod is already running and it held a lock on mongod.lock file. Run ps -eaf | grep mongod to find the running instance. If running, kill the process sudo kill <pID> obtained from above grep command.

Then delete the mongod.lock file as mongod wasn't shutdown gracefully. Post deleting the lock file start the mongod process sudo mongod.

Hope this helps!