Sometimes you may encounter an error when updating or installing a program in CentOS. Stay tuned to this article in Radib so that we can fix this problem together.

The "Failed to download metadata for repo 'AppStream'" error in CentOS usually occurs for the following reasons:

  1. Lack of access to repositories or internet problems.
  2. Repositories are disabled or redirected.
  3. Using an old or unsupported version of CentOS.

1. Checking the Internet Connection

First, make sure the server is connected to the Internet:

ping -c 4 google.com

If the connection is not established:

  • Check the network and DNS settings.
  • Change the proxy to 8.8.8.8 (as described earlier).

2. Checking access to CentOS repositories

curl -I http://mirror.centos.org

If no proper response is received, the default repositories may no longer be available.


3. Clearing old repository cache

sudo dnf clean all
sudo rm -rf /var/cache/dnf

And then reload the repositories:

sudo dnf makecache

4. Enable and update repositories

sudo dnf update --refresh

If the problem persists, check the repository files:

sudo nano /etc/yum.repos.d/CentOS-Base.repo

Make sure the links are as follows:

baseurl=http://mirror.centos.org/centos/$releasever/AppStream/$basearch/os/

5. Replacing Repository Mirrors

Sometimes the default repositories may not be available. To solve this problem:

Buy a high-quality virtual server from Radib, Click Now

Step 1: Install the alternative repository:

sudo dnf install epel-release

Step 2: Add alternative repositories:

sudo nano /etc/yum.repos.d/CentOS-Base.repo

And change Give:

baseurl=http://vault.centos.org/8.5.2111/AppStream/$basearch/os/

6. Update SSL and CA certificates

Sometimes the problem is due to invalid SSL certificates:

sudo dnf reinstall ca-certificates
sudo update-ca-trust

7. Check CentOS version

If you are running CentOS 8, please note that this version will no longer be supported by Red Hat as of 2021.

Buy hourly and monthly cloud servers, cheapest price, instant delivery, unlimited deletion and creation on Radib. Click Now.

  • Recommended Solution: Migrate to CentOS Stream 8 or AlmaLinux.
  • Install CentOS Stream:
sudo dnf install centos-release-stream
sudo dnf swap centos-linux-repos centos-stream-repos
sudo dnf distro-sync

Conclusion:

If the problem is not resolved after performing these steps, it is recommended to upgrade the operating system to newer versions or other equivalents such as AlmaLinux or Rocky Linux Upgrade.

Radib Group offers virtual servers with up-to-date operating systems and full support that can help resolve these types of issues faster.

Was this answer helpful? 392 Users Found This Useful (392 Votes)