All Products
Search
Document Center

:A yum command fails with the "HTTP Error 404 -Not Found Trying other mirror" prompt

Last Updated:Feb 06, 2024

This topic describes the possible causes of and solutions to a yum command failure. A yum command fails to run and the "HTTP Error 404 -Not Found Trying other mirror" prompt appears on an Elastic Compute Service (ECS) instance that runs a Linux OS.

Problem description

A yum command, such as yum -y install XXX, yum list, and yum search XXX, fails to be run on a Linux ECS instance. An error message similar to the following is displayed:

http://mirrors.cloud.aliyuncs.com/centos/7/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
Trying other mirror.
http://mirrors.cloud.aliyuncs.com/centos/$releasever/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
Trying other mirror.

Possible causes

This issue may occur because of the following reasons:

  • A source address of CentOS 6 or CentOS 8 was configured. The content at the source addresses of CentOS 6 and CentOS 8 has been removed because CentOS 6 and CentOS 8 have reached their ends of life (EOLs). For the solution, see Change the source address.

  • The YUM repository was not correctly configured and could not be parsed as expected. For the solution, see Change the base repository.

  • An HTTP proxy was configured in the /etc/profile file and caused a parsing failure. For the solution, see Modify the /etc/profile file.

  • The centos-release package was missing, which caused a $releasever parsing failure in the URL. For the solution, see Install the centos-release package.

Solutions

Change the source address

CentOS 6 and CentOS 8 have reached their EOLs and the Linux community no longer maintains the OS versions. In accordance with the community rules, the content at the source addresses of CentOS6 and CentOS 8 is removed. If you continue to use the default source address in a CentOS 6 or CentOS 8 OS, this error is reported. We recommend that you change the source address before you proceed. For more information, see Change the CentOS 6 source address and Change CentOS 8 repository addresses.

Change the base repository

In this example, CentOS 7.4 is used. For other OSs and OS versions, visit the Alibaba Cloud official image website.

  1. Connect to the ECS instance on which this error is reported.

    For more information, see Connection method overview.

  2. Run the following command to back up the existing base repository:

    mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
  3. Run the following command to download and install a new base repository:

    wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
  4. Run your yum command again to check whether the command runs as expected.

Modify the /etc/profile

  1. Connect to the ECS instance on which this error is reported.

    For more information, see Connection method overview.

  2. Run the following commands in sequence to check whether the instance can be pinged and port 80 is open on the instance:

    • If the instance cannot be pinged, the network is disconnected. In this case, check your network and try again.

    • If the instance can be pinged, go to the next step.

      ping mirrors.cloud.aliyuncs.com
      telnet mirrors.cloud.aliyuncs.com 80
  3. Run the following command to check whether the YUM repository can be accessed:

    curl http://mirrors.cloud.aliyuncs.com/centos/7/os/x86_64/repodata/repomd.xml -v

    An output similar to the following is returned and an HTTP proxy is configured on the instance.

    404

  4. Modify the environment variable file /etc/profile.

    1. Run the following command to open the /etc/profile file:

      vim /etc/profile
    2. Press i to enter the edit mode and add a number sign (#) before the HTTP proxy to comment out the proxy configuration. You can also modify the proxy configuration based on your business requirements.

      delete proxy

    3. After you edit the file, press the Esc key to exit the Insert mode and enter :wq to save the change and close the file.

    4. Run the following command to make the change take effect:

      source /etc/profile
  5. Run your yum command again to check whether the command runs as expected.

Install the centos-release package

In this example, CentOS 7.4 is used. For other OSs and OS versions, visit the Alibaba Cloud official image website.

  1. Connect to the ECS instance on which this error is reported.

    For more information, see Connection method overview.

  2. Download and install the centos-release package.

    wget https://mirrors.aliyun.com/centos/7/os/x86_64/Packages/centos-release-7-9.2009.0.el7.centos.x86_64.rpm
    rpm -ivh centos-release-7-9.2009.0.el7.centos.x86_64.rpm
  3. Run your yum command again to check whether the command runs as expected.