Slow DNF updates in AlmaLinux 9 are primarily caused by inefficient mirror selection, excessive parallel download limits, or large metadata sizes. The default mirrorlist often directs servers in regions like West Africa or remote areas to distant mirrors, causing significant latency.
To resolve this, configure the fastestmirror plugin and optimize DNF settings:
Install and enable fastestmirror:
sudo dnf install -y dnf-plugins-core
Edit /etc/dnf/dnf.conf to include these optimizations:
fastestmirror=True
max_parallel_downloads=10
timeout=60
Force direct base URLs if the mirrorlist remains slow (e.g., in Nigeria):
sed -Ei.bak 's/^mirrorlist=/# &/;s/^(# )(baseurl=.*)/\2/' /etc/yum.repos.d/almalinux-{appstream,baseos,extras}.repo
Clean stale metadata and test the fix:
sudo dnf clean all
sudo dnf makecache
sudo dnf update
If updates still fail or hang, disable IPv6 (add ipv6=disable to dnf.conf) or disable problematic repositories (e.g., —disablerepo=epel) to isolate conflicting metadata.