When MongoDB won't start on a RHEL-family server, the cause is usually one of a handful of things: a CPU that lacks the instructions MongoDB needs, wrong file ownership, SELinux, a port already in use, or a bad line in the config file. This guide shows how to find which one it is and fix it on AlmaLinux and Rocky Linux. It applies to your own VPS or server; MongoDB can't be installed on shared hosting.
Start with systemctl status mongod and journalctl -u mongod. If you see "Illegal instruction" or status=4/ILL, the CPU does not expose AVX, which MongoDB 5.0 and later need on x86_64: check with grep -o -w avx /proc/cpuinfo. The fix is a CPU that exposes AVX (on a VPS, ask your provider) or a hosted database such as MongoDB Atlas, not a downgrade to an end-of-life release. Other failures are usually permissions, SELinux, port 27017 or the config file, and the MongoDB log names the problem.
These steps are for a server where you have root access, such as a Domain India VPS. Shared hosting (cPanel, DirectAdmin, Webuzo) does not run MongoDB. On shared hosting, a Node.js app can connect to a hosted MongoDB service instead.
1. First look: status, journal and log
Run these three commands and read the output before you change anything:
sudo systemctl status mongod
sudo journalctl -u mongod -n 50 --no-pager
sudo tail -n 50 /var/log/mongodb/mongod.logThe journal shows how the process died. The MongoDB log, which is written as one JSON document per line, usually says why. To make it easier to read, filter for errors:
sudo grep -E '"s":"(E|F)"' /var/log/mongodb/mongod.log | tail -n 20"s":"F" lines are fatal errors and "s":"E" lines are errors. The msg and attr fields describe the problem.
| What you see | Likely cause | Go to |
|---|---|---|
| Illegal instruction, status=4/ILL, or traps in dmesg | CPU lacks AVX | Section 2 |
| Permission denied on the data or log directory | Wrong file ownership | Section 4 |
| Permission denied although ownership is right | SELinux | Section 4 |
| Address already in use | Port 27017 taken | Section 5 |
| Error parsing YAML config file | Bad mongod.conf | Section 5 |
| No space left on device | Disk full | Section 5 |
2. "Illegal instruction": check the CPU
On x86_64, MongoDB 5.0 and every later release are built for CPUs with AVX instructions. If the CPU, or the virtual CPU your VPS presents, doesn't expose AVX, mongod crashes the moment it starts. You'll see status=4/ILL in systemctl status, and the kernel log shows a trap:
sudo dmesg | grep -i -E 'mongod|trap'Check which instruction sets the CPU exposes:
grep -o -w -E 'avx|avx2|sse4_2' /proc/cpuinfo | sort -u
lscpu | grep -i -E 'model name|flags' | head -n 2If avx is missing from the output, current MongoDB releases cannot run on this machine as it is configured. On a virtual server this usually means the hypervisor presents a generic CPU model to the guest instead of the host's real CPU. You can't fix that from inside the VPS.
On ARM (aarch64) servers, MongoDB 5.0 and later need ARMv8.2-A or newer. Older ARM boards hit the same crash.
3. Fixing a missing-AVX problem
Older guides suggest installing MongoDB 4.4, which doesn't need AVX. MongoDB 4.4 reached end of life in February 2024 and gets no security fixes, and the same applies to 5.0 and 6.0. Running an unsupported database that stores customer data is a bigger risk than the crash. Compiling MongoDB from source without AVX is also not a realistic fix: the build is complex, unsupported, and the result has to be rebuilt for every update.
On a Domain India VPS, run the grep command above. If avx is missing, open a support ticket with the output and your VPS details, and support will tell you what can be done.
4. Permissions and SELinux
MongoDB runs as the mongod user, which must own its data and log directories. After a restore, a manual copy or running mongod once as root, these often end up owned by root:
ls -ld /var/lib/mongo /var/lib/mongodb /var/log/mongodb 2>/dev/null
sudo chown -R mongod:mongod /var/lib/mongo /var/log/mongodb
sudo systemctl restart mongodThe default data path in the official RHEL packages is /var/lib/mongo; check storage.dbPath in /etc/mongod.conf if you changed it.
On AlmaLinux and Rocky Linux, SELinux is enforcing by default. If ownership is right but you still see "Permission denied", look for SELinux denials:
getenforce
sudo ausearch -m avc -ts recent | grep mongodDon't switch SELinux off to make the error go away. MongoDB's installation guide for Red Hat Enterprise Linux describes its SELinux policy and the semanage fcontext commands needed when the data or log directory is in a non-default path.
5. Port, config file, disk and lock file
Port already in use. Another mongod, or a container, may already hold port 27017:
sudo ss -ltnp | grep 27017Config file errors. /etc/mongod.conf is YAML: indentation must use spaces, not tabs, and keys are case-sensitive. A single wrong indent stops the service. After editing, restart and read the log, which names the line it could not parse.
Disk full. df -h /var/lib/mongo shows free space. MongoDB stops writing when the disk fills, and the journal needs room to start.
After a crash. If the server lost power, MongoDB normally recovers from its journal on the next start. Don't delete files in the data directory to "clear a lock"; if it won't start after a crash, restore from a backup or follow MongoDB's repair guidance for your version.
6. Check the service and shell
The mongo shell used in older guides was removed in MongoDB 6.0. Use mongosh:
mongosh --eval 'db.runCommand({ ping: 1 })'A reply of { ok: 1 } means the server is running and accepting connections. For production, keep net.bindIp at 127.0.0.1 unless another server must connect, turn on authentication, and never open port 27017 to the whole internet. Allow it in the firewall only from the specific servers that need it.
7. Package and repository problems
On AlmaLinux and Rocky Linux, use dnf and the official MongoDB repository for your major version and OS release. If you have an old or wrong repository file, remove it and clean the cache before installing again:
sudo rm /etc/yum.repos.d/mongodb-org*.repo
sudo dnf clean allThen add the repository file for a currently supported MongoDB release, as shown in MongoDB's installation guide for Red Hat Enterprise Linux. CentOS Linux 7 and 8 are end of life, so new servers should use AlmaLinux or Rocky Linux instead.
8. MongoDB on Domain India
A Domain India VPS is self-managed with full root access and KVM virtualization, so you install and run MongoDB yourself; the live VPS page lists MongoDB among the databases you can run. Check for AVX first with the command in section 2. For setup steps see installing MongoDB on a Domain India VPS, and if you're still choosing a database, read choosing between PostgreSQL, MySQL, SQLite and MongoDB.
- 1 vCPU
- 2 GB DDR4 RAM
- 64 GB NVMe SSD Storage
- 2 TB Monthly Bandwidth
- 2 vCPU
- 4 GB DDR4 RAM
- 128 GB NVMe SSD Storage
- 3 TB Monthly Bandwidth
Prices on the cards are live and exclude 18% GST. Domain India VPS plans are self-managed, so MongoDB installation, updates and backups are your responsibility.
Why does MongoDB fail with "Illegal instruction"?
MongoDB 5.0 and later need a CPU with AVX instructions on x86_64. If the CPU, or the virtual CPU of a VPS, doesn't expose AVX, mongod crashes at start-up with status=4/ILL. Check with grep -o -w avx /proc/cpuinfo.
Should I downgrade to MongoDB 4.4 to avoid the AVX requirement?
No. MongoDB 4.4 reached end of life in February 2024 and gets no security fixes. Use a server whose CPU exposes AVX, or a hosted database such as MongoDB Atlas.
How do I check whether my VPS supports AVX?
Run grep -o -w -E 'avx|avx2' /proc/cpuinfo | sort -u. If avx is not listed, current MongoDB releases can't run there. On a VPS, ask your provider whether a CPU model with AVX can be presented to your server.
Where is the MongoDB log on AlmaLinux and Rocky Linux?
The official packages write to /var/log/mongodb/mongod.log. The service's own messages are in the journal, which you read with journalctl -u mongod.
The mongo command is not found. What should I use?
The legacy mongo shell was removed in MongoDB 6.0. Install and use mongosh, the current MongoDB shell.
Can I run MongoDB on Domain India shared hosting?
No. MongoDB needs a server you control. Run it on a VPS, or use a hosted MongoDB service and connect to it from your application.
Ready to run MongoDB on your own server? Compare the VPS plans, check AVX with the command above, and open a support ticket if the CPU check fails on a Domain India VPS.
Full root access, KVM virtualization and NVMe storage for MongoDB, PostgreSQL, Redis and your own applications.
See VPS plans