skip to Main Content

On my CentOS 8 server, many dnf and yum commands fail with this error:

Failed to download metadata for repo

This seems to apply only to repositories involving https connections, e.g.:

/etc/yum.repos.d $ cat epel-modular.repo
[epel-modular]
name=Extra Packages for Enterprise Linux Modular $releasever - $basearch/pub/epel/$releasever/Modular/$basearch
metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-modular-$releasever&arch=$basearch&infra=$infra&content=$contentdir
...

I have used wget to test connectivity to these sites and it is successful, e.g. wget https://mirrors.fedoraproject.org succeeds.

However, various dnf or yum commands fail:

$ dnf provides /bin/ls
Extra Packages for Enterprise Linux Modular 8 - x86_64     0.0  B/s |   0  B     00:00
Failed to download metadata for repo 'epel-modular'
Error: Failed to download metadata for repo 'epel-modular'

# dnf update --refresh
CentOS-8 - AppStream                                        20 kB/s | 4.3 kB     00:00
CentOS-8 - Base                                             19 kB/s | 3.8 kB     00:00
CentOS-8 - Extras                                          7.4 kB/s | 1.5 kB     00:00
CentOS-8 - PowerTools                                       20 kB/s | 4.3 kB     00:00
Remi's Modular repository for Enterprise Linux 8 - x86_64  4.1 kB/s | 3.5 kB     00:00
Safe Remi's RPM repository for Enterprise Linux 8 - x86_64 3.6 kB/s | 3.0 kB     00:00
Wazuh repository                                           0.0  B/s |   0  B     00:00
Failed to download metadata for repo 'wazuh_repo'
Error: Failed to download metadata for repo 'wazuh_repo'

How do I resolve this problem?

10

Answers


  1. Chosen as BEST ANSWER

    You may not realize it, but yum and dnf require SSL certificates when communicating via secure HTTP (aka HTTPS). Have you checked the certificates under /etc/pki/tls/certs? There should be at least two, for example:

    /etc/pki/tls/certs# ls -l
    total 4
    lrwxrwxrwx 1 root root   49 Jan 30 12:48 ca-bundle.crt -> /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem
    lrwxrwxrwx 1 root root   55 Dec 11 13:19 ca-bundle.trust.crt -> /etc/pki/ca-trust/extracted/openssl/ca-bundle.trust.crt
    

    If these links are missing you may be able to simply restore them. Otherwise, the files are part of the ca-certificates package. You can obtain them from another server running your operating system via yumdownloader then restore your certificates from the resulting RPM file using yum --nogpgcheck localinstall <RPM file>.


  2. In my case

    sudo rm -r /var/cache/dnf 
    

    solved my problem.

    Source: https://access.redhat.com/discussions/4222851

    Login or Signup to reply.
  3. If it does not work, check your Internet connection. This error appeared on my CentOS 8 installation, and the problem was that the Internet connection wasn’t correctly configured.

    Login or Signup to reply.
  4. I was facing this issue when I tried to run

    yum update -y
    

    from a docker container. I changed the version from centos:8 to centos:7 and it solved the issue for me.

    Login or Signup to reply.
  5. I was getting the same error with the Centos8 build inside of a docker container. Fixed by running the below:

    # Do on build
    RUN dnf clean all && rm -r /var/cache/dnf  && dnf upgrade -y && dnf update -y 
    

    Error before (i was running yum update and not dnf):

    Step 4/5 : RUN yum clean all && yum update -y && echo hostname -a
     ---> Running in 10d319da361d
    0 files removed
    CentOS-8 - AppStream                            0.0  B/s |   0  B     00:05    
    Failed to download metadata for repo 'AppStream'
    Error: Failed to download metadata for repo 'AppStream'
    

    Success after:

     ---> 0b96049ee5eb
    Step 4/5 : RUN dnf clean all && rm -r /var/cache/dnf  && dnf upgrade -y && dnf update -y & echo hostname
     ---> Running in f928c6da6cb0
    hostname
    Removing intermediate
    
    Login or Signup to reply.
  6. I had the same error after I was messing around with SD adapter to microSD card. Edit /etc/fstab to remove SD line solved the issue for me.

    Login or Signup to reply.
  7. Just add the following (DNS server) to /etc/resolv.conf file:

    nameserver 9.9.9.9
    

    Will fix the issue 🙂

    Login or Signup to reply.
  8. I will confirm I recently had this issue and what fixed it for me was a change in the DNS servers. I had a static IP set but DNS was automatic, I had to reconfigure DNS to use my gateway and dc. This is working now.

    Login or Signup to reply.
  9. I just faced this problem so I thought I’d add what fixed it for me since the resolution was pretty simple. For me, I was overlooking the fact that whenever I changed my hostname, it was wiping out everything in /etc/resolv.conf so I:

    1. nano -w /etc/resolv.conf **
    2. added the following lines:

      nameserver 8.8.8.8
      nameserver 8.8.4.4
      
    3. Test it (e.g. yum update -y)

    **note: I used nano in example, simply swap the nano portion for your own text editor of choice

    Login or Signup to reply.
  10. My issue was that the interface wasn’t up after a fresh vm install.
    Ran ifconfig to find my interface name and then ifup eXXX to get a dhcp ip address.

    Also don’t forget to change ONBOOT=no to ONBOOT=yes in /etc/sysconfig/network-scripts/ifcfg-eXXX so it comes up during next boot.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search