MongoDB didn't start because of File permission issue

Published: (February 27, 2026 at 03:52 PM EST)
2 min read
Source: Dev.to

Source: Dev.to

Cover image for MongoDB didn't start because of File permission issue

Original article published on Web Warrior Toolbox.

A Wired Tiger Turtle Story…

While troubleshooting a project, I wanted to run the database locally before deploying a hotfix. I set up my PC, mocked a database with useful test data, and later needed to test again with a local instance.

I tried to start MongoDB with the usual command:

systemctl start mongod

Checking the service status showed that it hadn’t started:

systemctl status mongod

The status output contained an error, but the reason wasn’t obvious. After consulting several chatbot suggestions, I realized the answer lay in the logs.

On Linux, application logs are stored under /var/log. For MongoDB, the relevant file is:

/var/log/mongodb/mongod.log

I inspected the last part of the log:

sudo tail -n300 /var/log/mongodb/mongod.log

Among the many lines, the most frequent and important message was:

[ERROR]: __posix_open_file, 924: /var/lib/mongodb/WiredTiger.turtle: handle-open: open: Permission denied

The error pointed to the file /var/lib/mongodb/WiredTiger.turtle. The chatbot suggested that this file should be owned by the mongodb user. It was owned by root, so I changed the ownership of the containing directory:

sudo chown -R mongodb:mongodb /var/lib/mongodb

After restarting the service, MongoDB started correctly:

systemctl restart mongod
systemctl status mongod

What I learned from that story

  • Check the logs: They often contain the exact error messages you need.
  • Use logs to inform chatbots or teammates: Providing the relevant log snippet can lead to faster resolutions.
  • File permissions matter: Ensure MongoDB files and directories are owned by the mongodb user.

Side story

Why did the WiredTiger.turtle file become owned by root? The first hotfix was run with:

sudo mongod --config /etc/mongod.conf

Running mongod directly with sudo caused the process to create files as root. Subsequent attempts to start MongoDB via systemctl failed due to the mismatched ownership. Changing the ownership back to mongodb resolved the issue.

Let’s keep coding, dev‑san 🤓 頑張って!

0 views
Back to Blog

Related posts

Read more »

The Last Dance with the past🕺

Introduction Hello dev.to community! A week ago I posted my first article introducing myself and explaining that I left web development to focus on cryptograph...