Could not retrieve mirrorlist http://mirrorlist.centos.org/ on CentOS 7
While updating the server OS or command that utilize the yum system, errors similar to the following are produced::
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was
14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Name or service not known"
On July 1st 2024 CentOS 7 is End of Life and the CentOS team has removed their mirrors from the internet. They can still be accessed via vault.centos.org
. Without updating the repository URLs, packages will be unable to be updated or validated, resulting in the error above.
IMPORTANT: Using the CentOS vault repository IS NOT to be used for staying on CentOS 7 for any longer than is required to migrate to a new server. Packages provided by the vault repository do not get any updates. This means that the software installed from the Vault repository will have unpatched security vulnerabilities and other defects. We suggest to reinstall the server with Almalinux/Rockylinux 8 or higher.
How to solve in Cpanel installed Servers
cPanel has released the following autofixer to enable the CentOS 7 Vault repository automatically for you:
/scripts/autorepair centos7_base_repo_is_no_more
Note: The above script will only correct servers with the repo file set as CentOS-Base.repo
, systems using custom repositories will need to edit the repo file to use vault.centos.org
using the manual steps below.
How to solve in other CentOS 7 Servers manually
If you are using a custom CentOS 7 base repository, then please follow these manual steps:
1. Copy the current CentOS 7 repository file so that you can revert the changes if necessary:
cp -v /etc/yum.repos.d/CentOS-Base.repo{,-backup}
Note: Your CentOS 7 base repository may have a different name. The above filename "CentOS-Base.repo" is only used as an example.
2. Edit the /etc/yum.repos.d/CentOS-Base.repo
file using a command line text editor
3. Paste in the following configuration:
[base]
name=CentOS-$releasever - Base
baseurl=https://vault.centos.org/7.9.2009/os/$basearch
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-$releasever - Updates
baseurl=https://vault.centos.org/7.9.2009/updates/$basearch
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
baseurl=https://vault.centos.org/7.9.2009/extras/$basearch
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
baseurl=https://vault.centos.org/7.9.2009/centosplus/$basearch
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
3. You now need to start your alias interface
4. Run the following command:
yum clean all && yum makecache