How to fix yum update on CentOS 7
2 min readUpdated 28 Oct 2026
CentOS 7 mirrors are gone. Point yum at the archive with one command, and plan the move to a supported system.
CentOS 7 reached its end of life on 30 June 2024. Its official mirrors were switched off, so yum update and yum install fail with errors such as:
Could not resolve host: mirrorlist.centos.org
Cannot find a valid baseurl for repo: base/7/x86_64
The packages still exist in the CentOS archive (the "vault"). The fix is to point yum at an archive mirror. It takes one command.
1. Back up the repository file
sudo cp /etc/yum.repos.d/CentOS-Base.repo /root/CentOS-Base.repo.bak
2. Point yum at the archive
Copy and run this as a single command:
sudo sed -i \
-e 's|^mirrorlist=|#mirrorlist=|g' \
-e 's|^#\{0,1\}baseurl=http://mirror.centos.org/centos/\$releasever/|baseurl=http://linuxsoft.cern.ch/centos-vault/7.9.2009/|g' \
/etc/yum.repos.d/CentOS-Base.repo
It disables the dead mirror list and sets the base, updates, extras and centosplus repositories to the CentOS 7.9 archive.
3. Refresh and update
sudo yum clean all
sudo yum makecache
sudo yum update -y
You can check the result with:
grep ^baseurl /etc/yum.repos.d/CentOS-Base.repo
Each line should now start with baseurl=http://linuxsoft.cern.ch/centos-vault/7.9.2009/.
If it still fails
- The error names another repository (for example
epel): that repository was archived too. Disable it for now withsudo yum-config-manager --disable epel, or ask us for help. - You prefer the official CentOS archive: replace
http://linuxsoft.cern.ch/centos-vault/7.9.2009/in the command above withhttps://vault.centos.org/7.9.2009/. Very old CentOS 7 installs may not trust its HTTPS certificate; the mirror above works over plain HTTP, and packages are still checked with the CentOS signing key. - To undo:
sudo cp /root/CentOS-Base.repo.bak /etc/yum.repos.d/CentOS-Base.repo
Plan a move to a supported system
The archive has no new security updates, and it never will. For anything exposed to the internet, move to a maintained system. AlmaLinux and Rocky Linux are the closest to CentOS (same commands, same package names), and Debian and Ubuntu are also available. You can pick any of them when you reinstall your VPS from the panel. A reinstall erases the server, so back up your data first.
