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:
- How to Migrate from CentOS 8 to Rocky Linux 8
- How to Migrate from CentOS 8 to AlmaLinux 8.5
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.