Failed to download metadata for repo ‘AppStream’
This error happens on trying to install packages in CentOS8. This is because CentOS Linux 8 had reached the End Of Life (EOL) on December 31st, 2021. That means CentOS 8 will no longer receive development resources from the official CentOS project.
So either we need to upgrade to CentOS Stream or update the mirrors to vault.centos.org.
This article explains the steps to configure the mirrors to vault.centos.org.
Step1: Login to the server as root via ssh.
Step2: Change the location to /etc/yum.repos.d/.
Step3: Disable old mirror list.
#sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
Step4: Update mirror list with vault.centos.org.
#sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*
Now it's possible to install or update the pacakges without any issues.