📖 ~1 min read
Table of contents
Symptom & Impact
Running dnf install or dnf update returns a lock error and exits before dependency resolution begins.
Environment & Reproduction
A previous dnf transaction, PackageKit activity, or an interrupted shell session left a lock in place.
Root Cause Analysis
Run ps -ef | grep -E ‘dnf|packagekit’ and sudo lsof /var/run/dnf.pid to identify active owners.
Quick Triage
If a valid transaction is still running, wait for completion and review progress with sudo journalctl -u packagekit -f.
Step-by-Step Diagnosis
When no process owns the lock, remove stale pid files carefully and clean cache with sudo dnf clean all.

Solution – Primary Fix
Rebuild metadata with sudo dnf makecache and rerun the original dnf command to confirm normal operation.
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
Verify the transaction list with sudo dnf history list and ensure no transaction is left in an incomplete state.
Verification & Acceptance Criteria
If the failed update partially changed packages, revert with sudo dnf history undo .
Rollback Plan
Avoid closing terminals during updates and disable overlapping automation windows that run package operations.
Prevention & Hardening
Create an alert for repeated lock messages in /var/log/dnf.log and PackageKit failures in journalctl.
Related Errors & Cross-Refs
Use a preflight script that exits when pgrep -x dnf or pgrep -x packagekitd returns a running process.
Related tutorial: View the step-by-step tutorial for rhel-9.
View all rhel-9 tutorials on the Tutorials Hub →
Browse all common problems & solutions on the Tutorials Hub.
References & Further Reading
Use man dnf and RHEL 9 package management guidance for lock behavior and recovery recommendations.
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.