Solution to "Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist" in CentOS.

Author
By Darío Rivera
Posted On in Linux

Recently, when running pipelines for some projects, we noticed that all of them were failing due to an error that seemed to be from BitBucket. After investigating the error a little further, it didn't seem to be so much of a BitBucket issue but rather a Docker image issue, which was producing the following error:

CentOS Linux 8 - AppStream
Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist

As you can see, this error appeared on CentOS 8, and this is because when attempting to install any packages using yum, the repository mirrors did not exist. CentOS officially archived the mirrors for version 8 and moved them to vault.centos.org.

Of course, the easiest solution for now, given that there are no official images for version 9 Stream, is to redirect the mirrors to the vault.

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

This solution is quick but opens up a short-term security breach, as the life of this version of CentOS has come to an end on December 31, 2021, and no updates to the packages will be provided after this date.


Acerca de Darío Rivera

Author

Application Architect at Elentra Corp . Quality developer and passionate learner with 10+ years of experience in web technologies. Creator of EasyHttp , an standard way to consume HTTP Clients.

LinkedIn Twitter Instagram

Sólo aquellos que han alcanzado el éxito saben que siempre estuvo a un paso del momento en que pensaron renunciar.