Failed to download metadata for repo ‘AppStream’ [CentOS]

When you run ‘yum update’ in a CentOS machine, you might get this error. You are probably doing this on a CentOS 8.2 machine or a VM that you just created using an old centos iso image. Then you get this error like below:

[root@smartsource1 ~]# yum update
CentOS-8 - AppStream 70 B/s | 38 B 00:00
Error: Failed to download metadata for repo 'AppStream': Cannot prepare internal mirrorlist: No URLs in mirrorlist

This is because on 31st Dec 2021, CentOS 8 had reached its EOL. So you can either upgrade to CentOS Stream or you can point your yum repository to the archives by executing the below commands.

cd /etc/yum.repos.d/
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-*
yum update -y

Now your yum update should work fine as we have pointed the repos to the archives.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.