CentOS 7 has reached its End of Life (EOL), which means its repositories may no longer be maintained and accessible. However, you can still use some workarounds to keep your CentOS 7 system functional by pointing to alternative or archived repositories.
sudo bash -c "$(wget -qO- https://raw.githubusercontent.com/AtlasGondal/centos7-eol-repo-fix/main/centos7_eol_fix.sh)"
sudo cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
# use curl
sudo curl -fsSL https://raw.githubusercontent.com/AtlasGondal/centos7-eol-repo-fix/main/CentOS-Base.repo -o /etc/yum.repos.d/CentOS-Base.repo
# or use wget
# sudo wget -O /etc/yum.repos.d/CentOS-Base.repo https://raw.githubusercontent.com/AtlasGondal/centos7-eol-repo-fix/main/CentOS-Base.repo
Clear the YUM cache to ensure it fetches the latest repository metadata:
sudo yum clean all
sudo yum makecache
Now try updating your system:
sudo yum update
sudo cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
Open the repository file with a text editor:
sudo nano /etc/yum.repos.d/CentOS-Base.repo
Replace the baseurl
entries with the following vault URLs:
[base]
name=CentOS-$releasever - Base
baseurl=http://vault.centos.org/7.9.2009/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
[updates]
name=CentOS-$releasever - Updates
baseurl=http://vault.centos.org/7.9.2009/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
[extras]
name=CentOS-$releasever - Extras
baseurl=http://vault.centos.org/7.9.2009/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Save the file and exit the editor.
Clear the YUM cache to ensure it fetches the latest repository metadata:
sudo yum clean all
sudo yum makecache
Now try updating your system:
sudo yum update