Fixed Failed to Download Metadata for Repo AppStream CentOS Linux 8

Table of Contents

Failed to Download Metadata for Repo AppStream CentOS Linux 8

In this post, we will take you through the steps to solve Failed to download metadata for repo AppStream error which I was getting in a CentOS 8 Linux Server.

# cat /etc/centos-release
CentOS Linux release 8.2.2004 (Core)

# yum update -y
CentOS-8 - AppStream                               62  B/s |  38  B     00:00
Error: Failed to download metadata for repo 'AppStream':
Cannot prepare internal mirrorlist: No URLs in mirrorlist

This problem can be encountered in any of the CentOS 8 system which is still in use post December 31st, 2021. The reason is because CentOS 8 had already reached its End of Life (EOL) on this date which means that it will no longer receive any development updates from official CentOS Project.

But if you are still thinking to use or already using this OS after Dec 31st, 2021 due to any reason then you need to change the mirror to Vault where it will be archived permanently like it happened for other older CentOS versions.

To fix the above error, we need to change the repo URL pointing from official CentOS URL to vault.centos.org.

1. SSH to your remote Linux server using an administrative account.

Note

Please note that we’re using root user to run all the below commands. You can use any user with sudo access to run all these commands.

2. Run the following commands to change the mirror list in /ect/yum.repos.d/ directory:

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-*
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-*

Alternatively, you can also point to the Cloudflare-based vault repository, by running the following commands:

sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-Linux-*
sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.epel.cloud|g' /etc/yum.repos.d/CentOS-Linux-*
sed -i 's/mirrorlist/mirrorlist/g' /etc/yum.repos.d/CentOS-Linux-*
sed -i 's|baseurl=http://mirror.centos.org|baseurl=http://vault.epel.cloud|g' /etc/yum.repos.d/CentOS-Linux-*

3. Once the mirror is changed and updated, we can now try to update again by using dnf update or yum update command as shown below. This time it works fine as expected.

[root@centos8 ~]# yum update -y

CentOS-8 - AppStream                                                                     28 MB/s | 8.4 MB     00:00
CentOS-8 - Base                                                                          13 MB/s | 4.6 MB     00:00
CentOS-8 - Extras                                                                       165 kB/s |  10 kB     00:00
CentOS-8 - PowerTools                                                                   5.3 MB/s | 2.3 MB     00:00
Extra Packages for Enterprise Linux Modular 8 - x86_64                                   13 kB/s | 9.6 kB     00:00
Extra Packages for Enterprise Linux Modular 8 - x86_64                                   23 kB/s | 733 kB     00:32
Extra Packages for Enterprise Linux 8 - x86_64                                          8.3 kB/s | 9.1 kB     00:01
Extra Packages for Enterprise Linux 8 - x86_64                                          808 kB/s |  13 MB     00:16
Dependencies resolved.
========================================================================================================================
 Package                             Architecture Version                                        Repository        Size
========================================================================================================================
Installing:
 centos-linux-release                noarch       8.5-1.2111.el8                                 BaseOS            22 k
     replacing  centos-release.x86_64 8.2-2.2004.0.1.el8
     replacing  centos-repos.x86_64 8.2-2.2004.0.1.el8
 kernel                              x86_64       4.18.0-348.7.1.el8_5                           BaseOS           7.0 M
 kernel-core                         x86_64       4.18.0-348.7.1.el8_5                           BaseOS            38 M
 kernel-modules                      x86_64       4.18.0-348.7.1.el8_5                           BaseOS            30 M

Leave a Comment

Required fields are marked *