If you, for one reason or the other, are still actively using CentOS 8, you might probably have encountered the following error when trying to update your system or simply install a package.
“Error: Failed to download metadata for repo ‘appstream’: Cannot prepare internal mirrorlist: No URLs in mirrorlist”
For example, in the screenshot that follows, I was trying to install the fio package and run into it.
What is the Cause of This Error?
You may well be aware that CentOS Linux 8 died a premature death, it reached the End Of Life (EOL) on December 31st, 2021, thus it no longer receives development resources from the official CentOS project.
This means that after Dec 31st, 2021, to update your CentOS installation, you are required to change the mirrors to CentOS Vault Mirror, where they will be archived permanently.
Fix Error: Failed to Download Metadata for Repo ‘AppStream’
To fix the above error, open your terminal or login via ssh, and run the following commands to change the repo URL to point to vault.centos.org, from the official CentOS repos.
Here we use the sed command to edit the required directives or parameters in the repo configuration files:
# 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-*
Now you should be able to update CentOS or install packages without any error:
If you wish to migrate from CentOS 8 to Rock Linux 8 or AlamLinux 8, check these guides:
That’s all! We hope that this guide helped you fix the above-aforementioned error. Use the comment form below to share feedback with us, you can ask questions as well.
Great! Following your steps worked for me as well.
Thank you for the clear instructions on fixing the ‘Failed to Download Metadata for Repo ‘AppStream’‘ error.
It works, thanks for trick
This is used for CentOS Linux, but in the case of centos appstream use the following trick
Go to /etc/yum.repos.d.
Add in CentOS-Stream-AppStream.repo
baseurl=http://mirror.centos.org/centos/8-stream/AppStream/x86_64/os/
Add in CentOS-Stream-BaseOS.repo
baseurl=http://mirror.centos.org/centos/8-stream/BaseOS/x86_64/os/
Add in CentOS-Stream-Extras.repo
baseurl=http://mirror.centos.org/centos/8-stream/extras/x86_64/os/
CentOS-Stream-Extras-common.repo
baseurl=https://vault.centos.org/centos/8-stream/extras/Source/extras-common/