About this article: This article is reviewed against the cited sources. This is source research, not lab validation. Check the stated versions and your own requirements before making changes.
When mongod stops with NonExistentPath: Data directory /data/db not found, the directory it was told to use as its data directory does not exist. The message text comes from the MongoDB source code (release r8.0.38), which ends it "Create the missing directory or specify another path using (1) the --dbpath command line option, or (2) by adding the 'storage.dbPath' option in the configuration file." Do not create the directory yet. Often the real data is somewhere else, and an empty directory only gives you a second, empty database.
What the error means
mongod keeps its data files in one directory, set by storage.dbPath in the configuration file or by --dbpath on the command line. The MongoDB manual gives the default as /data/db on Linux and macOS, and says the setting is "The directory where the mongod instance stores its data."
The package installs use a different default. The manual's directory-paths page says the packaged configuration file sets the data directory to /var/lib/mongo on RHEL, SUSE and Amazon Linux, and to /var/lib/mongodb on Debian and Ubuntu. It also says "Packages that install MongoDB on Linux-based operating systems place the configuration file at /etc/mongod.conf. When you start MongoDB through systemd, it automatically loads this configuration."
So /data/db appearing in the error usually means one of two things. mongod was started by hand without --config, so it fell back to its built-in default. Or a configuration file really does name a path that is missing.
In the MongoDB source code, the error code NonExistentPath is returned when the data directory does not exist. The program builds the message from the format Data directory followed by the directory, then not found. Create the missing directory or specify another path using (1) the --dbpath command line option, or (2) by adding the 'storage.dbPath' option in the configuration file. Only the directory varies. Other messages come from the same start-up check and point to different faults:
Unable to check existence of data directory <path>, followed by an operating-system error, means the check itself failed, for example because a parent directory cannot be searched.Attempted to create a lock file on a read-only directorymeans the directory exists but mongod may not write to it.Unable to create/open the lock fileandUnable to lock the lock filemean the directory exists and either permissions are wrong or another mongod already holds it.
Likely causes
| Cause | What you see | How to confirm |
|---|---|---|
mongod started by hand with no --config or --dbpath |
The path in the error is exactly /data/db |
The command that started it has no --config; /etc/mongod.conf names a different dbPath |
| The config names a path that was never created or is misspelt | The path in the error is the config's path | The directory is missing when you list it |
| The data volume was not mounted when mongod started | The path in the error is the config's path, but the data is on a volume | The mount is absent in the mount table for that path |
| A different config file is loaded than you expect | The path in the error does not match /etc/mongod.conf |
The service definition shows another --config path |
| Data moved to a new location and the config was not updated | The old path is in the config | The new location holds the data files |
Prove the cause before changing anything
All of these are read-only.
1. How was mongod started? If it runs under systemd, look at the unit and its last messages:
systemctl status mongod --no-pager
systemctl cat mongod
journalctl -u mongod -n 50 --no-pager
systemctl cat prints the unit file, including the command line in ExecStart. journalctl -u limits output to one unit and -n sets the number of lines. If ExecStart has --config /etc/mongod.conf, the service reads that file. Note the User= line if the unit has one. If you started mongod from a shell, look at the command you typed.
2. What does the config say?
grep -n dbPath /etc/mongod.conf
Replace the path if the unit named another file. Note the value. The manual also warns that "The Linux package init scripts included in the official MongoDB packages depend on specific values for systemLog.path, storage.dbPath, and processManagement.fork or MONGODB_CONFIG_OVERRIDE_NOFORK system environment variable", so a changed value on a packaged install is worth a second look.
3. Does that path exist, and who owns it?
ls -ld /var/lib/mongodb
namei -l /var/lib/mongodb
ls -ld lists the directory itself, not its contents. namei -l shows the owner and mode of every component of the path, which finds a parent directory that cannot be searched. A good result shows a directory owned by the account that runs mongod. A bad result is an error from the command saying the path cannot be accessed because it does not exist.
4. Which filesystem holds the path?
findmnt --target /var/lib/mongodb
--target accepts any file or directory and reports the filesystem it is on. If the data should sit on its own volume, the output must name that volume, not the root filesystem.
5. Where is the real data? Look at the places an earlier setup might have used, such as the other package default, /data/db, or a volume mount point. List the candidates read-only:
ls -la /data/db /var/lib/mongo /var/lib/mongodb
A directory that the config does not name and that holds many files is the likely data directory.
Fix
Work in this order. The first two fixes change nothing on disk except configuration or the service state.
Start mongod with its config file
If mongod was started by hand without --config, the fix is to start it the way the install intended. For a packaged install that means the service.
First record the current state of the service:
systemctl status mongod --no-pager > /root/mongod-status-2026-11-22.txt
Disruptive step: the next command starts mongod, which opens the data files in the dbPath named by the configuration file and accepts client connections.
Start it:
systemctl start mongod
systemctl status mongod --no-pager
To undo it: stop the service again with systemctl stop mongod. The saved file shows what the state was before.
Correct a wrong dbPath in the configuration
Use this when the config names a path that does not exist, and step 5 found the data elsewhere.
First save the current file and the current state of the service:
cp -p /etc/mongod.conf /etc/mongod.conf.2026-11-22
systemctl status mongod --no-pager > /root/mongod-status-before-edit-2026-11-22.txt
Risk: the next edit changes the directory mongod uses for every database it serves, and the start that follows opens that directory. A wrong value either fails again or points mongod at a directory that holds different data. The manual says the Linux package init scripts "do not expect storage.dbPath to change from the defaults", and that if you change it with the Linux packages "you must use your own init scripts and disable the built-in scripts".
Edit /etc/mongod.conf so that storage.dbPath is the directory you found in step 5, and check the line. The manual says you configure mongod at startup with a configuration file, so the change does nothing until mongod is started:
grep -n dbPath /etc/mongod.conf
Disruptive step: the next command starts mongod on the directory the edited file names.
systemctl start mongod
systemctl status mongod --no-pager
To back out: stop the service if it started, then put the saved file back under its own name and check the line. If the saved status file shows it was running before the edit, start it again after the copy.
systemctl stop mongod
cp -p /etc/mongod.conf.2026-11-22 /etc/mongod.conf
grep -n dbPath /etc/mongod.conf
The data volume is not mounted
If findmnt --target shows the root filesystem where a data volume should be, an administrator mounts the volume with the storage tools of that server, outside this procedure. Creating a directory at the path in the meantime is the wrong response. mongod would then start on an empty directory and report an empty deployment while the real data waits on the unmounted volume.
Create the directory (last resort)
Use this only when step 5 found no data anywhere, as on a new server, and the config names the path you want.
First show that the directory is absent:
ls -ld /var/lib/mongodb
The expected result is an error from ls saying it cannot access the path because it does not exist. If the directory exists, stop here: it already has an owner and may hold data, and none of the commands below apply.
Risk: the next commands create a new, empty data directory. A mongod started on it is a new, empty deployment. If the real databases are elsewhere, they will not appear.
Create it and give it to the account that runs mongod. The manual says that by default on Linux MongoDB runs as the mongod user, so use the account named by the User= line of systemctl cat mongod if there is one and it differs. chown with only an owner changes the owner and leaves the group alone:
mkdir /var/lib/mongodb
chown mongod /var/lib/mongodb
To undo it: show the directory, confirm it is the one you created and is empty, then remove it. rmdir removes a directory only if it is empty.
ls -la /var/lib/mongodb
rmdir /var/lib/mongodb
Example (illustrative): db01 is rebuilt after a disk replacement. An engineer starts mongod from a shell with mongod and no options. It stops with NonExistentPath: Data directory /data/db not found. systemctl cat mongod shows ExecStart with --config /etc/mongod.conf, and grep -n dbPath /etc/mongod.conf shows /var/lib/mongodb. ls -ld /var/lib/mongodb shows the directory exists, and ls -la /var/lib/mongodb shows it holds the data files. The engineer's shell command never read the config file, so it used the default /data/db. Running systemctl start mongod starts the server on the right data, and nobody creates /data/db.
Confirm the fix
systemctl status mongod --no-pagershows the service running, not failed.journalctl -u mongod -n 50 --no-pagerhas no newNonExistentPathline.- Connect with the shell and list the databases you expect to see.
- After a reboot, the service starts by itself and finds the same data.
What to watch afterwards
- Start mongod only through its service or with
--config. A command typed without options uses/data/db. - Put the data volume mount ahead of mongod in the boot order, so the path exists when the service starts.
- Keep the config file under change control. A copy with a dated name before every edit makes a bad value easy to reverse.
- Check the other start-up messages above if the error changes. Each points to a different fault.
Read next
Related articles you may want next.
- Backup & RecoveryMongoDB backups: what mongodump can and cannot do, filesystem snapshots, and restoring a replica setHow MongoDB backups really work: mongodump and --oplog limits, filesystem snapshot requirements, restore version rules and restoring a replica set correctly.Read article
- Troubleshootingsystemd: "Job for nginx.service failed because the control process exited with error code" - find the real errorJob for nginx.service failed because the control process exited? Read systemctl status and journalctl, decode the exit status, test the config.Read article
- TroubleshootingA Linux Filesystem Became Read-Only: Preserve the First ErrorSeparate a policy read-only mount from an error response and preserve the evidence needed for safe offline repair decisions.Read article
Risks and limits
- These commands have not been run or lab-tested.
- The message wording comes from the MongoDB source code at release r8.0.38. Other releases may word it differently, and the manual does not print the message.
- The MongoDB manual describes the Linux packages. Container images, tarball installs and distribution-built packages may use other paths and accounts.
- SELinux policy: the MongoDB SELinux policy page says the policy cannot be used when a custom dbPath is set. Systems that enforce SELinux need separate handling for a non-default path.
- Starting mongod on the wrong directory can create a second, empty deployment. Prove where the data is before you start the service.
Sources
- Self-Managed Configuration File Options (storage.dbPath) — MongoDB 9.0 manual, no date shown, accessed 22 November 2026
- mongod (--dbpath, --config) — MongoDB 9.0 manual, no date shown, accessed 22 November 2026
- Default Data and Log Directory Paths — MongoDB 9.0 manual, no date shown, accessed 22 November 2026
- Configure the MongoDB SELinux Policy — MongoDB 9.0 manual, no date shown, accessed 22 November 2026
- storage_engine_lock_file.cpp — MongoDB source code, release tag r8.0.38, no date shown, accessed 22 November 2026
- storage_engine_lock_file_posix.cpp — MongoDB source code, release tag r8.0.38, no date shown, accessed 22 November 2026
- systemctl — systemd manual, no date shown, accessed 22 November 2026
- journalctl — systemd manual, no date shown, accessed 22 November 2026
- ls(1) — GNU coreutils 9.11 manual page, April 2026, accessed 22 November 2026
- mkdir(1) — GNU coreutils 9.11 manual page, April 2026, accessed 22 November 2026
- chown(1) — GNU coreutils 9.11 manual page, April 2026, accessed 22 November 2026
- rmdir(1) — GNU coreutils 9.11 manual page, April 2026, accessed 22 November 2026
- cp(1) — GNU coreutils 9.11 manual page, April 2026, accessed 22 November 2026
- namei(1) — util-linux manual page, 2026-05-24, accessed 22 November 2026
- findmnt(8) — util-linux manual page, 2026-08-03, accessed 22 November 2026
- grep(1) — GNU grep manual page, 2025-03-21, accessed 22 November 2026
This article was originally published on .