If you are using CentOS 8, you may have noticed that installing packages with yum does not work any longer and often results in an error message like this:
Error: Failed to download metadata for repo ‘appstream’: Cannot prepare internal mirrorlist: No URLs in mirrorlist
Furthermore, this error may also occur when we use Docker container images based on CentOS 8.
This error started occurring on January 31, 2022, as the CentOS team removed all CentOS 8 packages from the official mirrors. These packages have been moved to this link.
We can easily resolve the “CentOS Error: No URLs in mirrorlist” by migrating to CentOS Stream 8. However, if that is not a possibility at the moment, our experts have a quick solution:
We have to update the repos in /etc/yum.repos.d in order to use vault.centos.org rather than mirror.centos.org . We can do this with these commands:
sudo sed -i -e "s|mirrorlist=|#mirrorlist=|g" /etc/yum.repos.d/CentOS-* sudo sed -i -e "s|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g" /etc/yum.repos.d/CentOS-*
In other words, we are replacing the base URL. Although this will resolve the error for now, we will not receive any further updates for CentOS 8. Our experts recommend upgrading to the Stream version sooner rather than later.