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
You may not realize it, but
yum
anddnf
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: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 usingyum --nogpgcheck localinstall <RPM file>
.In my case
solved my problem.
Source: https://access.redhat.com/discussions/4222851
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.
I was facing this issue when I tried to run
from a docker container. I changed the version from centos:8 to centos:7 and it solved the issue for me.
I was getting the same error with the Centos8 build inside of a docker container. Fixed by running the below:
Error before (i was running yum update and not dnf):
Success after:
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.Just add the following (DNS server) to /etc/resolv.conf file:
Will fix the issue 🙂
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.
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:
nano -w /etc/resolv.conf
**added the following lines:
yum update -y
)**note: I used nano in example, simply swap the
nano
portion for your own text editor of choiceMy issue was that the interface wasn’t up after a fresh vm install.
Ran
ifconfig
to find my interface name and thenifup eXXX
to get a dhcp ip address.Also don’t forget to change
ONBOOT=no
toONBOOT=yes
in/etc/sysconfig/network-scripts/ifcfg-eXXX
so it comes up during next boot.