Table of Contents
Errors During Downloading Metadata for Repository Baseos
[root@cs8 ~]# cat /etc/os-release
NAME="CentOS Linux"
VERSION="8"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="8"
PLATFORM_ID="platform:el8"
PRETTY_NAME="CentOS Linux 8"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:8"
HOME_URL="https://centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"
CENTOS_MANTISBT_PROJECT="CentOS-8"
CENTOS_MANTISBT_PROJECT_VERSION="8"
In this post, we will take you through the steps to solve Failed to download metadata for repo AppStream error which we were getting in a CentOS 8 Linux Server.
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 Linux 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.
[bonben@centos8 ~]$ sudo dnf update -y
CentOS Linux 8 - AppStream 26 kB/s | 8.1 kB 00:00
Errors during downloading metadata for repository 'appstream':
- Status code: 404 for http://mirror.centos.org/centos/8/AppStream/x86_64/os/repodata/repomd.xml (IP: 204.15.73.245)
Error: Failed to download metadata for repo 'appstream': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried
CentOS Linux 8 - BaseOS 41 kB/s | 8.1 kB 00:00
Errors during downloading metadata for repository 'baseos':
- Status code: 404 for http://mirror.centos.org/centos/8/BaseOS/x86_64/os/repodata/repomd.xml (IP: 69.4.80.162)
Error: Failed to download metadata for repo 'baseos': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried
Ignoring repositories: appstream, baseos
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 using below commands.
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-*
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
Not a reader? Watch this related video tutorial: