CentOS 8: No URLs in mirrorlist error [How to Solve]

Question:

In CentOS 8, there is an error using yum. There is no URL in the image list, similar to the following:

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

reason:

On January 31, 2022, the CentOS team finally removed all packages of CentOS 8 from the official image.

CentOS 8 has expired on December 31, 2021, but the software package has been retained on the official image for some time. Now they are transferred to https://vault.centos.org

Solution:

If you still need to run CentOS 8, you can run it in/etc/yum repos. Update the source in D. Use vault.centos.Org instead of mirror.centos.org.

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-*

Essentially, it replaces the previous URL with the URL that is still running. This problem should be solved within this period of time.

Read More: