📖 ~1 min read
Table of contents
Symptom & Impact
`dnf` reports the lock is held by a dead PID and refuses to run.
Environment & Reproduction
Common after a killed dnf or container exit mid-transaction.
Root Cause Analysis
Stale lock files in /var/lib/rpm and /var/cache/dnf remain after crash.
Quick Triage
Check with `lsof /var/lib/rpm/.rpm.lock` and `fuser` on the path.
Step-by-Step Diagnosis
Confirm no live rpm/dnf process, then identify the stale PID in metadata.

Solution – Primary Fix
Remove the lock with `rm -f /var/lib/rpm/.rpm.lock` after verifying no holder.
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 in maintenance.
Verification & Acceptance Criteria
`dnf makecache` completes without lock errors.
Rollback Plan
Restore lock state from backup if ACLs were changed.
Prevention & Hardening
Configure `nice`/`ionice` and monitor for OOM during package ops.
Related Errors & Cross-Refs
Linked to OOM events and forced reboots during upgrade.
Related tutorial: View the step-by-step tutorial for centos-stream-9.
View all centos-stream-9 tutorials on the Tutorials Hub →
Browse all common problems & solutions on the Tutorials Hub.
References & Further Reading
CentOS Stream 9 RPM and dnf locking reference.
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.