The "rpmdb open failed" error means the RPM database is corrupted. This prevents yum from installing, updating, or removing packages, and can block cPanel updates and EasyApache builds. The fix is to rebuild the RPM database.
Rebuild the RPM database: rpm --rebuilddb. If that fails, remove the stale lock files first: rm -f /var/lib/rpm/__db.* then rpm --rebuilddb.
01. Symptoms
The error typically looks like:
error: rpmdb: BDB0113 Thread/process 12345/140123456789 failed: BDB1507 Thread died in Berkeley DB library
error: db5 error(-30973) from dbenv->failchk: BDB0087 DB_RUNRECOVERY: Fatal error, run database recovery
error: cannot open Packages index using db5 - (-30973)
error: cannot open Packages database in /var/lib/rpm
CRITICAL:yum.main:
Error: rpmdb open failed
You'll see this when running yum, rpm, cpanel update, or any operation that queries the package database.
02. Rebuilding the RPM Database
# Step 1: Back up the current database
cp -a /var/lib/rpm /var/lib/rpm.bak.$(date +%Y%m%d)
# Step 2: Remove stale Berkeley DB files
rm -f /var/lib/rpm/__db.*
# Step 3: Rebuild the database
rpm --rebuilddb
# Step 4: Verify yum works
yum check-update
The rebuild process can take 1-5 minutes depending on how many packages are installed. Don't interrupt it.
03. Clearing Stale Locks
If the rebuild fails or yum reports another process is using the database:
# Check for running yum/rpm processes
ps aux | grep -E "yum|rpm" | grep -v grep
# Kill any stuck processes
kill -9 $(pgrep -f "yum|rpm")
# Remove lock files
rm -f /var/lib/rpm/__db.*
rm -f /var/lib/rpm/.dbenv.lock
rm -f /var/lib/rpm/.rpm.lock
# Try rebuild again
rpm --rebuilddb
Make sure no legitimate yum or rpm processes are running before killing processes and removing locks. Running rpm --rebuilddb while another rpm operation is active can make the corruption worse.
04. Prevention
Don't kill yum/rpm processes - Let package operations complete. Interrupting them is the most common cause of RPM database corruption.
Don't run concurrent yum operations - Multiple simultaneous yum commands corrupt the database. Use yum-cron for automatic updates rather than overlapping manual runs.
Monitor disk space - If /var fills up during a yum transaction, the database write can be incomplete.
Schedule regular checks - Add rpm --rebuilddb to a weekly cron as a preventive measure if corruption recurs.
Database Still Corrupted?
If rpm --rebuilddb doesn't fix it or if the corruption keeps recurring, the underlying issue may be disk I/O errors or filesystem corruption. Open a ticket for investigation.
Quick Recap: Fixing RPM Database Errors
- Back up first -
cp -a /var/lib/rpm /var/lib/rpm.bak - Remove stale files -
rm -f /var/lib/rpm/__db.* - Rebuild -
rpm --rebuilddb - Verify -
yum check-update - Prevent recurrence - Never interrupt yum/rpm operations
Last updated March 2026 · Browse all Server Maintenance articles
