Could not retrieve mirrorlist http://mirrorlist.centos.org/ on CentOS 7


INTRODUCTION

On 2024-06-30 CentOS 7 became End of Life (EOL)

Red Hat has removed the 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.

When running various functions such as MultiPHP 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"


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.


READ ME FIRST

This article is provided as a courtesy.
Installing, configuring, and troubleshooting third-party applications is outside the scope of basic support provided by Starburst Services.

We are not liable for any damages and/or data loss.


REQUIRMENTS

  • SSH credentials or File Manager access Logged In as Root
  • Text editor of your choice (The example uses nano)

THIS IS ONLY A TEMPORARY WORKAROUND

PROCEDURE

STEP 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.


STEP 2

Edit the file:

nano /etc/yum.repos.d/CentOS-Base.repo

STEP 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

STEP 4

Save the edited file.

In nano, use Ctrl-O to Save, and Ctrl-X to Exit.


STEP 5

Run the following command:

yum clean all

Configuration is complete.

You are ready to go.


If migrating to AlmaLinux, please visit the AlmaLinux ELevate page at:

https://almalinux.org/elevate


Thanks for learning with Starburst Services.

Learn more about our services


KB Article Created: 2024-07-10

Thanks to Zachary Karr for which this article is based on.

people found this article helpful. What about you?