Fix dnf that will not install
We'll check connectivity, repo config, disk space, and locks—then fix repo URLs, GPG keys, or metadata—or tell you when to escalate.
What you'll need
- SSH or console access with sudo
Step-by-step diagnostic
Quick triage — pick your path
Get started
Choose the option that matches what you see. You can jump straight to that section.
Show full guide
Steps
Goal: Check connectivity, repo config, disk space, and locks—then fix repo URLs, GPG keys, or metadata.
- Run
sudo dnf install <package>. Note the exact error. - Good: You see a specific error (connection, 404, GPG, disk full, lock). Proceed to Check connectivity.
- Bad: dnf hangs—check connectivity and timeouts.
Check error and connectivity
Goal: Confirm the error and test repo reachability.
- Run
dnf repolistand inspect/etc/yum.repos.d/*.repofor baseurl or metalink. - Test with
curl -I <baseurl>orpingthe host. If unreachable, the repo URL or mirror is wrong. - Run
df -hand confirm/and/varhave free space. dnf needs space in/var/cache/dnf. - Good: Repo is reachable and disk has space. Proceed to Fix repo config if needed, or Clear metadata.
- Bad: Repo unreachable or disk full—fix the repo URL or free space first.
Fix repo config
Goal: Fix baseurl or metalink so dnf can reach the repo.
- Edit the .repo file in
/etc/yum.repos.d/. Set baseurl to a known-good mirror (e.g. vault.rockylinux.org for old Rocky). Check that enabled=1. - Run
sudo dnf clean allandsudo dnf makecache. Retrysudo dnf install <package>. - If the error is GPG-related, import the key with
sudo rpm --import <key-url>or temporarily set gpgcheck=0 to test—do not leave disabled in production. - Good: Metadata loads and packages install. Bad: Same error—check connectivity again or escalate.
Clear metadata
Goal: Remove corrupted metadata and retry.
- Run
sudo dnf clean allto clear cached metadata. Thensudo dnf makecacheandsudo dnf install <package>. - Good: Install succeeds. Bad: Escalate with the error and repo config.
When to escalate
Escalate if:
- The repo is managed by a central team and you cannot change it.
- The mirror is enterprise-internal and unreachable from your network.
- The fix requires network or firewall changes outside your control.
Provide: the dnf error, dnf repolist output, and contents of /etc/yum.repos.d/*.repo.
Verification
sudo dnf install <package>completes without errors.- The package is installed and
rpm -q <package>shows the version. - No GPG or connection errors in the output.
Escalation ladder
Work from the device outward. Stop when the problem is fixed.
- Capture error Run dnf install; note exact error.
- Connectivity and disk Test repo URL with curl; check df -h.
- Repo config Edit baseurl/metalink; dnf clean all; makecache.
- GPG keys Import correct key or temporarily disable gpgcheck to test.
- Escalate Enterprise-managed repo or infrastructure change needed.
What to capture if you need help
Before calling support or posting for help, have these ready. It speeds everything up.
- Exact dnf error message
- Output of dnf repolist
- Contents of /etc/yum.repos.d/*.repo
- df -h and disk usage
Does dnf install show a specific error?
Run sudo dnf install <package> and note the error: connection, 404, GPG, disk full, or lock.
You can change your answer later.
Check connectivity and timeouts
Can you reach the repo URL?
Test with curl -I or ping. Repo must return HTTP 200 or be reachable.
You can change your answer later.
Fix repo URL and retry
Is disk space sufficient?
dnf needs space in /var and /var/cache/dnf.
You can change your answer later.
Is another dnf process holding the lock?
Only one dnf process can run at a time.
You can change your answer later.
Wait or remove stale lock
Is the error GPG-related?
GPG key retrieval failed or GPG check failed.
You can change your answer later.
Import GPG key and retry
Clear metadata and retry
Escalate
Reviewed by Blackbox Atlas
Frequently asked questions
- Why would dnf install fail?
- Network or repo URL unreachable, expired or wrong GPG key, full disk, another dnf/yum process holding the lock, or corrupted metadata. Check the error message first.
- Can I fix dnf install myself?
- Yes. Check connectivity, repo config, disk space, and locks. Fix baseurl or metalink, import GPG keys, clear metadata with dnf clean all, or remove stale lock files.
- When should I escalate dnf install failures?
- If the repo is enterprise-managed and you cannot change it, or the fix requires infrastructure changes outside your control.
Rate this guide
Was this helpful?
Thanks for your feedback.