Symptoms 

 Yum update on CentOS 5 server failed with below errors

https://support.solus.io/hc/en-us/articles/360018764892-Yum-update-failing-on-CentOS-5

[root@vz yum.repos.d]yum update
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
YumRepo Error: All mirror URLs are not using ftp, http[s] or file.
Eg. Invalid release/repo/arch combination/
removing mirrorlist with no valid mirrors: /var/cache/yum/base/mirrorlist.txt
Error: Cannot find a valid baseurl for repo: base
[root@vz yum.repos.d]#

Cause

 Since the CentOS 5 EOL, the CentOS-Base.repo is invalid now.

Resolution

  1. Login to the server via SSH.
  2. Rename the /etc/yum.repos.d/CentOS-Base.repo file:

    mv /etc/yum.repos.d/CentOS-Base.repo{,.orig}

  3. Run the below command to create the empty configuration file:

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

  4. Edit the created file using the below command:

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

    It should look like the one below:

    # CentOS-Base.repo
    #
    # The mirror system uses the connecting IP address of the client and the
    # update status of each mirror to pick mirrors that are updated to and
    # geographically close to the client. You should use this for CentOS updates
    # unless you are manually picking other mirrors.
    #
    # If the mirrorlist= does not work for you, as a fall back you can try the
    # remarked out baseurl= line instead.
    #
    #
    [base]
    name=CentOS-$releasever - Base
    mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
    baseurl=http://vault.centos.org/5.11/os/x86_64/
    #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
    #released updates
    [updates]
    name=CentOS-$releasever - Updates
    mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
    baseurl=http://vault.centos.org/5.11/updates/x86_64/
    #baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
    #additional packages that may be useful
    [extras]
    name=CentOS-$releasever - Extras
    mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
    baseurl=http://vault.centos.org/5.11/extras/x86_64/
    #baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

  5. Run yum update command:

    yum update