Hi guys, we will talk about an error may be faced you while using yum or dnf package manager for CentOS
For example: When you tried to update the system using yum update you will see this error message: Failed to download metadata for repo.
It will be like below:
dnf update CentOS Linux 8 - AppStream 130 B/s | 38 B 00:00 Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist
- For Debug information you can show the logs output by running:
Fix Failed to download metadata for repo
CentOS Linux 8 had reached the End Of Life (EOL) on December 31st, 2021. that’s means CentOS 8 will no longer receive development resources from the official CentOS project.
After Dec 31st, 2021, if you need to update your CentOS, you need to change the mirrors to vault.centos.org where they will be archived permanently.
So just follow the steps below to do that
- Go to the /etc/yum.repos.d/ directory.
- Run the below commands to hash the mirror-list in all yum.repos.d files then replace the existed Baseurl with the vault.centos.org
sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*
- Then run yum update or install any package you want
yum update -y
Everything will be OK after you do the steps above.
We illustrated how to fix the Failed to download metadata for repo error related to (Failed to download metadata for repo ‘appstream’: Cannot prepare internal mirrorlist: No URLs in mirrorlist) error.
Thanks, I tried but did not work for me, the same error