CentOS 8 Maintenance in 2024

If you're encountering issues with yum or dnf on CentOS 8, such as an error stating No URLs in mirrorlist, this article will explain the cause and how to resolve it.

The error message typically looks like this:

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

This problem arises because the CentOS team removed all CentOS 8 packages from their official mirrors on January 31, 2022. Although CentOS 8 reached its end-of-life on December 31, 2021, the packages remained available on official mirrors for a brief period. Now, these packages have been moved to https://vault.centos.org.

To address this issue, the recommended solution is to migrate to CentOS Stream 8. This involves updating the repositories in /etc/yum.repos.d to use vault.centos.org instead of mirror.centos.org to make the package managers work without the above mentioned error. Here are two commands to facilitate this change:

sudo sed -i -e "s|mirrorlist=|#mirrorlist=|g" /etc/yum.repos.d/CentOS-*

and

sudo sed -i -e "s|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g" /etc/yum.repos.d/CentOS-*

After updating the repositories, you can proceed to upgrade CentOS 8 to CentOS Stream 8.

  1. Update all packages and libraries of the CentOS Linux 8 operating system. To do so, enter the following command:

    sudo dnf update
  2. After the update you might need to run the sed commands again as they are being reset to their original configurations.
  3. Install the centos-release-stream package for access to CentOS Stream repositories. To do so, enter the following command:

    sudo dnf install centos-release-stream
  4. Change the default repository to the CentOS Stream repository. To do so, enter the following command:

    sudo dnf swap centos-{linux,stream}-repos
  5. Synchronize the installed packages and libraries from the new default repository. To do so, enter the following command:

    sudo dnf distro-sync
  6. Restart the operating system. To do so, enter the following command:

    sudo reboot

Resources

The post is heavily based on the following resources.

  1. CentOS 8: No URLs in mirrorlist error
  2. Migrating CentOS Linux 8 to CentOS Stream 8