"Failed to synchronize cache for repo" / "Cannot prepare internal mirrorlist"
dnf or yum could not reach the repository metadata. The curl error number in the message identifies the cause precisely.
What you see
Any dnf operation fails at the metadata stage. Curl error 6 is DNS, 7 is connection refused, 60 is certificate validation, 28 is timeout.
What is actually wrong
DNS, a proxy, an expired CA bundle, a clock that is wrong enough to invalidate certificates, or — on CentOS 7 and CentOS 8 — mirrors that no longer exist because the distribution went end of life.
Codes and articles
Fixes (2)
Work through the curl error
A supported distribution whose repositories should still exist.
Get the full error including the curl number.
sudo dnf clean all && sudo dnf makecache 2>&1 | tail -20Curl error 6 — DNS. Test resolution.
getent hosts mirrors.rockylinux.orgcat /etc/resolv.conf
Curl error 60 — certificate. Check the clock first, then the CA bundle.
timedatectlsudo update-ca-trust extract
A clock wrong by more than the certificate's validity window makes every HTTPS mirror fail validation, and the error says nothing about time.
Curl error 7 or 28 — connectivity or proxy. Set the proxy in dnf's own config if one is needed.
grep -i proxy /etc/dnf/dnf.conf /etc/yum.conf 2>/dev/nullcurl -sS -o /dev/null -w '%{http_code}\n' https://mirrors.rockylinux.org
Test one repository at a time to find which is broken.
sudo dnf repolist --allsudo dnf makecache --repo=baseos
Disable a repository that is genuinely gone rather than letting it block everything.
sudo dnf config-manager --set-disabled brokenrepo
sudo dnf makecache && sudo dnf repolistRepoint a CentOS 7 or 8 system at the vault
CentOS 7 or CentOS 8. The mirrorlist service no longer answers for these, so this is not a network fault — the mirrors are gone.
Confirm the version.
cat /etc/centos-releaseBack up the repo files before editing them.
sudo cp -a /etc/yum.repos.d /etc/yum.repos.d.bakComment out the mirrorlist lines and point baseurl at vault.centos.org.
sudo sed -i -e 's/^mirrorlist=/#mirrorlist=/' -e 's|^#\?baseurl=http://mirror.centos.org|baseurl=https://vault.centos.org|' /etc/yum.repos.d/CentOS-*.repoThe vault holds the final released packages. It receives no security updates — this restores the ability to install, not the ability to patch.
Rebuild the cache.
sudo yum clean all && sudo yum makecacheUnderstand this is a holding action. The system is out of support and receives no security fixes; plan a migration to Rocky, Alma or RHEL.
Leaving an EOL distribution on the network indefinitely is a far bigger problem than the one being fixed here.
sudo yum repolistRelated faults
Where this stops. This write-up was written and checked by hand. It says what each step changes, how to confirm it worked and how to reverse it, and anything destructive is flagged before you reach it. If it does not match what your machine is doing, search the Support Centre for the exact code or message — and when something needs a person, get in touch.