Fixing “Cannot retrieve metalink” EPEL Repository Error on CentOS 6 x86_64


2 views

When working with legacy CentOS 6 systems, you might encounter the following error when trying to use yum with EPEL repositories:

Error: Cannot retrieve metalink for repository: epel. Please verify its path and try again

The primary cause is that CentOS 6 reached End of Life (EOL) in November 2020, and many repository mirrors have been discontinued or moved. The metalink files (which dynamically determine the best mirror) are no longer properly maintained.

Here are three approaches to resolve this:

Option 1: Disable Metalink and Use Base URL

Edit the EPEL repo file:

# vi /etc/yum.repos.d/epel.repo

Make these changes:

[epel]
name=Extra Packages for Enterprise Linux 6 - $basearch
#baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch
failovermethod=priority
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6

Change to:

[epel]
name=Extra Packages for Enterprise Linux 6 - $basearch
baseurl=http://archive.kernel.org/centos-vault/6.10/extras/$basearch/
failovermethod=priority
enabled=1
gpgcheck=0  # Temporarily disable if GPG keys fail

Option 2: Use Vault Archives

Replace your entire repo configuration with vault archives:

# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
# wget -O /etc/yum.repos.d/CentOS-Base.repo https://raw.githubusercontent.com/CentOS/sig-core-t_functional/master/CentOS6-Vault.repo
# yum clean all
# yum makecache

Option 3: Manual Package Installation

For critical packages, download them directly:

# wget http://vault.centos.org/6.10/extras/x86_64/Packages/example-package.rpm
# rpm -ivh example-package.rpm

1. Consider upgrading to a supported CentOS version if possible
2. For production systems, evaluate alternative repositories like IUS or maintaining local mirrors
3. Always verify package integrity when using unofficial sources


When working with legacy CentOS 6 systems, you might encounter this specific error when trying to use EPEL repository:

Error: Cannot retrieve metalink for repository: epel. Please verify its path and try again

This typically occurs because CentOS 6 reached EOL (End of Life) on November 30, 2020, and many repository mirrors have been discontinued or moved.

The EPEL repository for CentOS 6 originally used metalinks to automatically find the fastest mirror. With most official mirrors offline, the metalink resolution fails. Here's what's happening behind the scenes:

# Debugging command to see the actual metalink URL
yum --disablerepo="*" --enablerepo="epel" repolist -v

Solution 1: Use the Vault URL Directly

Modify your EPEL repository configuration to point directly to the CentOS Vault:

# Backup original file first
cp /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.bak

# Edit the epel.repo file
sed -i 's/mirrorlist=https/metadata_expire=never\nbaseurl=https:\/\/archives.fedoraproject.org\/pub\/archive\/epel\/6\/$basearch\//g' /etc/yum.repos.d/epel.repo
sed -i 's/#baseurl=/baseurl=/g' /etc/yum.repos.d/epel.repo

Solution 2: Disable Metalink and Enable BaseURL

Manually edit /etc/yum.repos.d/epel.repo:

[epel]
name=Extra Packages for Enterprise Linux 6 - $basearch
baseurl=http://archives.fedoraproject.org/pub/archive/epel/6/$basearch
failovermethod=priority
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
metadata_expire=never

Solution 3: Alternative Mirror Configuration

If the vault URL is slow, try this alternative:

[epel]
name=EPEL for CentOS 6 (Archive)
baseurl=https://repo.huaweicloud.com/epel/6/$basearch
enabled=1
gpgcheck=1
gpgkey=https://repo.huaweicloud.com/epel/RPM-GPG-KEY-EPEL-6

After making changes, always clear the yum cache and test:

yum clean all
yum makecache
yum list available --disablerepo=* --enablerepo=epel

Remember that CentOS 6 is no longer receiving security updates. For production systems, consider:

  • Migrating to CentOS 7 or 8
  • Using CentOS Stream
  • Evaluating alternatives like Rocky Linux or AlmaLinux

Once EPEL is working, you can install packages as usual:

# Example: Installing htop
yum --enablerepo=epel install htop

For a more permanent solution, add EPEL to the enabled repositories list:

yum-config-manager --enable epel