100

Fix MongoDB Error 100 'Cannot Recover' Fast

MongoDB error 100 stops your database cold. I'll show you three fixes: restart the service, repair the data, or rebuild from a backup.

That Error 100 — Why It Shows Up

You start MongoDB and see it crash with cannot recover, error code 100. This usually happens after a power loss, a hard shutdown, or a disk that ran out of space. The database can't read its own journal files or data files properly. I know how frustrating this is — I lost a dev database this way once and had to rebuild from a backup. Good news: most of the time you can fix it without losing data.

Quick Fix: Restart MongoDB Service (30 seconds)

This sounds dumb, but it works more often than you'd think. MongoDB might have had a temporary glitch or the journal file was in a weird state from a prior crash.

  1. Stop MongoDB — on Ubuntu/Debian: sudo systemctl stop mongod. On Windows: net stop MongoDB.
  2. Wait 5 seconds.
  3. Start it again: sudo systemctl start mongod or net start MongoDB.
  4. Check the logs: tail -100 /var/log/mongodb/mongod.log. If you see recovery complete and no error 100, you're good.

If it still crashes with error 100, move to the next fix.

Moderate Fix: Repair the Database (5 minutes)

This rebuilds the data files and journal. MongoDB's mongod --repair command checks every document and throws away damaged ones. You might lose a few records, but the database will start.

  1. Stop MongoDB completely.
  2. Locate your data directory. Default is /var/lib/mongodb on Linux, C:\Program Files\MongoDB\Server\4.0\data on Windows.
  3. Run repair pointing to that path:
    mongod --dbpath /var/lib/mongodb --repair
    On Windows: mongod --dbpath "C:\Program Files\MongoDB\Server\4.0\data" --repair
  4. Wait for it to finish — it can take 10–15 minutes for a large database. The output will say repair done or completed successfully.
  5. Start MongoDB normally: sudo systemctl start mongod.
  6. Check if error 100 is gone. If not, try the next step.

Advanced Fix: Restore from Backup (15+ minutes)

This is the nuclear option. If repair fails or you see cannot recover even after repair, the data files are too far gone. I've seen this when the disk had bad sectors or the journal had inconsistent writes.

  1. Stop MongoDB if it's running.
  2. Move the corrupted data directory to a safe place:
    sudo mv /var/lib/mongodb /var/lib/mongodb_corrupted
  3. Create a fresh data directory:
    sudo mkdir -p /var/lib/mongodb
    sudo chown mongodb:mongodb /var/lib/mongodb
  4. Start MongoDB — it should start clean now. Check with sudo systemctl status mongod.
  5. Restore your latest backup. If you used mongodump, run:
    mongorestore /path/to/backup/folder
  6. If you don't have a backup, you're out of luck — that's why I always set up automated backups after this happened to me.

Preventing Error 100 in the Future

  • Always shut down MongoDB cleanly with db.shutdownServer() from the mongo shell.
  • Use a UPS for your server — power loss is the #1 cause of this error.
  • Monitor disk space. MongoDB needs free space to write journal files. Set up alerts at 80% usage.
  • Enable journaling — it's on by default in MongoDB 3.2+, but double-check your config file has storage.journal.enabled: true.

If none of these fixes work, post your MongoDB version (check with mongod --version) and the full error log. I'll help you dig deeper.

Related Errors in Database Errors
Database Login Page Shows Connection Refused After Update Cannot add foreign key constraint MySQL 'Cannot add foreign key constraint' Error Fix SQL Server 'Database in Restoring' state Why Your SQL Server Keeps Throwing 'Database in Restoring' State Error establishing a database connection Fix 'Database Error: Cannot Connect to MySQL' on WordPress

Was this solution helpful?

EP
Erropedia Team
Tech Support Editors
The Erropedia editorial team researches and documents real-world tech errors from across Windows, Linux, macOS, networking, databases, cloud platforms, and more. Every solution is reviewed for accuracy and updated as software and systems evolve.