Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

yum/dnf error: Failed to download metadata for repo [closed]

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?

like image 783
CODE-REaD Avatar asked Jan 30 '20 20:01

CODE-REaD


People also ask

Which is an example of failed to download metadata for Repo?

For example: When you tried to update the system using yum update you will see this error message: Failed to download metadata for repo. dnf update CentOS Linux 8 - AppStream 130 B/s | 38 B 00:00 Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist

Does Yum uninstall all of your Repos at once?

Don't worry -- it doesn't remove any repos, it simply temporarily ignores all of yours, and downloads information regarding the new mirrors. You may at this point want to actually upgrade your packages: You'll now be able to use "yum" as usual.

When does DNF metadata expire?

[root@localhost ~]# dnf update Last metadata expiration check: 0:03:09 ago on Thu 05 May 2022 11:27:35 PM EDT.

Do yum and DNF require SSL?

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:


2 Answers

In my case

sudo rm -r /var/cache/dnf 

solved my problem.

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

like image 66
nepalipunk Avatar answered Sep 29 '22 17:09

nepalipunk


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
like image 45
Edwrd_T_Justice Avatar answered Sep 29 '22 18:09

Edwrd_T_Justice