📖 ~1 min read
Table of contents
Symptom & Impact
Subsequent `dnf` invocations report a lock held by a dead PID, blocking all package operations.
Environment & Reproduction
Common when previous dnf process was killed forcefully or a container exited mid-transaction.
Root Cause Analysis
Stale lock files in /var/lib/rpm and /var/cache/dnf are not cleaned up automatically.
Quick Triage
Quickly list locks with `lsof /var/lib/rpm/.rpm.lock` and `fuser /var/lib/rpm/.rpm.lock`.
Step-by-Step Diagnosis
Confirm no live dnf or rpm process exists, then identify the stale PID in lock metadata.

Solution – Primary Fix
Remove the stale lock with `rm -f /var/lib/rpm/.rpm.lock` after verifying no live process holds it.
Still having issues? Our IT Solutions & Services team can diagnose and resolve this for you. Get in touch for a free consultation.

Solution – Alternative Approaches
Restart `packagekit` and retry the operation in single-user maintenance.
Verification & Acceptance Criteria
`dnf makecache` and `dnf check-update` complete without lock errors.
Rollback Plan
Restore lock state from backup if filesystem ACLs were inadvertently modified.
Prevention & Hardening
Configure `nice` and `ionice` settings to prevent OOM kills during heavy package operations.
Related Errors & Cross-Refs
Frequently linked to OOM events and unexpected reboots during upgrade.
Related tutorial: View the step-by-step tutorial for centos-stream-10.
View all centos-stream-10 tutorials on the Tutorials Hub →
Browse all common problems & solutions on the Tutorials Hub.
References & Further Reading
CentOS Stream 10 RPM and dnf locking reference materials.
Need Expert Help?
If you cannot resolve this yourself, our team offers hands-on Server Management, Managed IT Services, and flexible Support Plans. Contact us today — we respond within one business day.