cPanel Error: rpmdb open failed

We often run into the error while updating the yum on cPanel/WHM servers.

Error:

rpmdb: Thread/process 29586/140397819602848 failed: Thread died in Berkeley DB library
error: db3 error(-30974) from dbenv->failchk: DB_RUNRECOVERY: Fatal error, run database recovery
error: cannot open Packages index using db3 – (-30974)
error: cannot open Packages database in /var/lib/rpm
CRITICAL:yum.main:

Error: rpmdb open failed

It usually occurs when the RPM database is corrupted on the server

To fix this error, Login to your Server/VPS via SSH with root credentials.

Then we try to stash all the files used by the yum repository for the dependency resolution:

yum clean headers

Clean yum packages cache:

yum clean packages

Then we clean metadata:

yum clean metadata

Clean dbcache:

yum clean dbcache

Clean remaining:

yum clean all

Remove clean all RPM database files:

rm -f /var/lib/rpm/__db.*

Rebuilt RPM Database:

rpm -vv –rebuilddb

Finally, we run the update command:

yum update

To resolve this error, we can also try to rebuild the RPM database using the Rebuild RPM database tool in WHM:

“WHM Home » Software » Rebuild RPM Database”