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?
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
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.
[root@localhost ~]# dnf update Last metadata expiration check: 0:03:09 ago on Thu 05 May 2022 11:27:35 PM EDT.
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:
In my case
sudo rm -r /var/cache/dnf
solved my problem.
Source: https://access.redhat.com/discussions/4222851
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With