Skip to content
ohsudo, Home
Linux

yum "Cannot find a valid baseurl for repo": CentOS 7 reached end of life, so use the vault

Fix yum "Cannot find a valid baseurl for repo: base/7/x86_64" and the CentOS 8 mirrorlist error: point the repositories at vault.centos.org, then plan a migration.

Beginner3 min readApplies to CentOS 7 · CentOS 8 · CentOS Stream 8 · Docker images centos:7 and centos:8

by OhSudo ·

Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=container error was
14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error"
...
Cannot find a valid baseurl for repo: base/7/x86_64

On CentOS 8, the same problem looks like this:

Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: Curl error (6): Couldn't resolve host name for http://mirrorlist.centos.org/?release=8&arch=x86_64&repo=AppStream&infra=container [Could not resolve host: mirrorlist.centos.org]

Your network is probably fine. CentOS 7 reached its end of life on June 30, 2024, and CentOS 8 at the end of 2021. Their mirrors were switched off, and mirrorlist.centos.org no longer exists. The packages were kept, though, on vault.centos.org, which is an archive and receives no more updates.

TL;DR

On CentOS 7, as root:

Terminal window
sed -i -e 's/^mirrorlist=/#mirrorlist=/' \
-e 's|^#baseurl=http://mirror.centos.org/centos/$releasever|baseurl=http://vault.centos.org/7.9.2009|' \
/etc/yum.repos.d/CentOS-*.repo
yum clean all
yum makecache

Then plan to move off CentOS 7: section 4.

1. Make sure it’s the end-of-life problem

Terminal window
cat /etc/centos-release
grep -E '^(mirrorlist|baseurl)' /etc/yum.repos.d/CentOS-Base.repo

CentOS Linux release 7.9.2009, with mirrorlist=http://mirrorlist.centos.org/..., is the case this article covers. If the message names another repository, such as EPEL or a vendor’s, or you’re on a supported system, then it’s a network problem: section 5.

2. CentOS 7: point to the vault

The commands above do two things in each CentOS repository file. They turn off the mirrorlist line, and turn on baseurl, now pointing to the archive of the last release, 7.9.2009. Check the result:

Terminal window
grep -E '^(#?mirrorlist|baseurl)' /etc/yum.repos.d/CentOS-Base.repo
yum repolist

In a Dockerfile, put the same line before your first yum:

FROM centos:7
RUN sed -i -e 's/^mirrorlist=/#mirrorlist=/' \
-e 's|^#baseurl=http://mirror.centos.org/centos/$releasever|baseurl=http://vault.centos.org/7.9.2009|' \
/etc/yum.repos.d/CentOS-*.repo \
&& yum -y install httpd \
&& yum clean all

Better still, change the base image, as section 4 explains. The Dockerfile Generator starts from supported images.

3. CentOS 8: the same idea

Terminal window
sed -i -e 's/^mirrorlist=/#mirrorlist=/' \
-e 's|^#baseurl=http://mirror.centos.org/$contentdir/$releasever|baseurl=http://vault.centos.org/8.5.2111|' \
/etc/yum.repos.d/CentOS-*.repo
dnf clean all
dnf makecache

8.5.2111 was the last CentOS Linux 8 release.

4. Then move on

The vault gets the system installing packages again. It doesn’t get you security updates: nothing published since the end of life, including fixes for serious vulnerabilities. So treat the vault as a bridge, and plan the way off:

From To How
CentOS 7 Rocky Linux, AlmaLinux or RHEL 8/9 AlmaLinux’s ELevate project upgrades in place, or rebuild on a fresh install
CentOS 8 Rocky Linux or AlmaLinux 8 Their migrate2rocky and almalinux-deploy scripts convert in place
A Docker image rockylinux:9, almalinux:9, or a smaller base Change the FROM line, and test

A fresh install, with your configuration applied by a tool such as Ansible, is often the cleanest route. In-place conversion works, though test it on a copy first, and take a backup.

Red Hat’s extended support, ELS, still exists for RHEL 7, and other vendors sell extended CentOS 7 support. That’s the option when a system can’t move yet.

5. When it’s really the network

On a supported system, this message means yum or dnf can’t reach a working mirror at all:

Terminal window
curl -sI https://mirrors.rockylinux.org/ | head -n 1
getent hosts mirrors.rockylinux.org
env | grep -i proxy

No name resolution is a DNS problem: see Temporary failure in name resolution. A company proxy needs proxy=http://proxy:3128 in /etc/yum.conf or /etc/dnf/dnf.conf. A firewall may block outgoing HTTP and HTTPS. And a repository file you added by hand may simply have a wrong URL.

Warning

Don’t use random mirrors from forums that claim to still serve CentOS updates, and don’t add sslverify=0 or gpgcheck=0 to get past errors. Packages are signed so that you can trust them. Keep gpgcheck=1 with the CentOS key that’s already installed, which also covers the vault.

Shell, we have a problem!

Similar, but different: on Debian and Ubuntu, an old release gives 404 Not Found or does not have a Release file, fixed with old-releases.ubuntu.com or archive.debian.org. NO_PUBKEY is a missing signing key on apt. Unable to locate package is about apt’s package list. And dpkg was interrupted is an install cut short.

Found this useful? Share it.

Found a mistake? Let us know at contact@ohsudo.com.

Tools

Try it yourself

Articles

Related articles