Skip to content

Fix rpmdb open failed and cannot open Packages database Errors in dnf

Updated 2 min read

Updated: 29 September 2026 · Applies to: dnf and RPM 4.16 to 4.19 on AlmaLinux and Rocky Linux 9 and 10, RHEL 9 and 10

When the RPM package database cannot be opened, dnf and rpm stop with errors such as:

error: sqlite failure: CREATE TABLE IF NOT EXISTS 'Packages' (...): database disk image is malformed
error: cannot open Packages index using sqlite - No such file or directory (2)
error: cannot open Packages database in /var/lib/rpm

dnf shows the same lines. We reproduced them on AlmaLinux 9 with a damaged copy of the database. On CentOS 7 (end of life since June 2024), yum reported the same problem as Error: rpmdb open failed.

On CentOS 7 and older this usually came from stale Berkeley DB lock files (/var/lib/rpm/__db.*), and old guides tell you to delete them. Current AlmaLinux, Rocky Linux and RHEL releases store the database in a single SQLite file, so there are no __db files to delete, and yum clean headers or dbcache no longer exist. Work through these checks instead.

1. Is another package tool running?

pgrep -a 'rpm|dnf|yum|packagekit'

If an update is running, for example from dnf-automatic or PackageKit, wait for it to finish. Stop PackageKit with systemctl stop packagekit if it holds the database.

2. Is the disk full?

df -h / /var /usr
df -i / /var

A full file system, or one without free inodes, is a common cause. Free space first, then try again.

3. Clean dnf's cache

dnf clean all
dnf makecache

This only removes downloaded repository data and packages; it does not touch the installed-package database. If dnf still fails with the same error, the database itself is damaged.

4. Rebuild the database

cp -a "$(rpm -E %_dbpath)" /root/rpmdb-backup-$(date +%F)
rpmdb --verifydb
rpmdb --rebuilddb
rpm -qa | wc -l

Back up first, as shown. After the rebuild, rpm -qa should list your packages again and dnf check should report no problems. For the full procedure, including what to do if the rebuild fails, see how to recover from a corrupt RPM database.

Then update

dnf upgrade

Official documentation: RPM documentation and dnf command reference.

Related services

KVM VPS hosting

NVMe SSD and full root access, with Free Basic Managed Support.

Unmanaged dedicated servers

full root access and free IPMI KVM, with Free Basic Managed Support.

Linux server management

hardening, patching, monitoring and automation for Ubuntu, Debian, RHEL and AlmaLinux.

Was this answer helpful?

Still stuck? Open a ticket