Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. Devops
  3. Question
Devops

MongoDB: Exception In InitAndListen: 20 Attempted To Create A Lock File On A Read-Only Directory: /Data/Db, Terminating

Asked by Alison Kelly Nov 23, 2022 2.0K views 2 answers
Share

About this question

 I created /data/db in root directory and ran ./mongodb:

[initandlisten] exception in initAndListen: 20 Attempted to create a lock file on a read-only directory: /data/db, terminating 

[initandlisten] shutdown: going to close listening sockets... [initandlisten] shutdown: going to flush dialog... [initandlisten] now exiting [initandlisten] shutting down with code:100

Your answer

2 Answers

Ranjana Admin JanBask Expert Latest answer

Answered on Jun 20, 2024

The error message Exception in initAndListen: 20 Attempted to create a lock file on a read-only directory: /data/db, terminating in MongoDB indicates that MongoDB is trying to create a lock file in the /data/db directory, but it does not have the necessary write permissions to do so. This typically happens due to permission issues or incorrect directory ownership.


To resolve this issue, follow these steps:


1. Check the Directory Permissions

Ensure that the MongoDB process has the correct permissions to write to the /data/db directory.

Was this helpful?

More Devops discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest DevOps Blogs

Guides, tips and career advice on DevOps from JanBask experts.