Failed to download metadata for repo

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

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:
tail /var/log/dnf.log

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.
cd /etc/yum.repos.d/
  •  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

For example:

Everything will be OK after you do the steps above.

Conclusion

That’s it

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.

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"
MQ-Jr
MQ-Jr
unixcop Admin

2 COMMENTS

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest articles

Join us on Facebook