Ошибка не удалось загрузить метаданные для репозитория

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...

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?

Edwrd_T_Justice's user avatar

asked Jan 30, 2020 at 20:00

CODE-REaD's user avatar

2

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

answered Mar 8, 2020 at 8:16

Edwrd_T_Justice's user avatar

2

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

answered Apr 29, 2020 at 22:41

Scott White's user avatar

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.

james.garriss's user avatar

answered Feb 10, 2020 at 13:14

david.t_92's user avatar

david.t_92david.t_92

1,9111 gold badge10 silver badges15 bronze badges

1

Just add the following (DNS server) to /etc/resolv.conf file:

nameserver 9.9.9.9

Will fix the issue :)

halfer's user avatar

halfer

19.7k17 gold badges95 silver badges183 bronze badges

answered Apr 4, 2020 at 12:21

Yazan Yahya's user avatar

3

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.

answered Mar 5, 2020 at 6:52

Raj Shirolkar's user avatar

1

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>.

halfer's user avatar

halfer

19.7k17 gold badges95 silver badges183 bronze badges

answered Jan 30, 2020 at 20:00

CODE-REaD's user avatar

CODE-REaDCODE-REaD

2,6993 gold badges32 silver badges59 bronze badges

1

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.

answered Mar 27, 2020 at 10:47

Al Po's user avatar

Al PoAl Po

83211 silver badges20 bronze badges

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.

answered Apr 23, 2020 at 14:15

SysUser's user avatar

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.

Mickael B.'s user avatar

Mickael B.

4,5774 gold badges23 silver badges46 bronze badges

answered May 1, 2020 at 23:51

ICTSOL's user avatar

1

If you, for one reason or the other, are still actively using CentOS 8, you might probably have encountered the following error when trying to update your system or simply install a package.

Error: Failed to download metadata for repo ‘appstream’: Cannot prepare internal mirrorlist: No URLs in mirrorlist

For example, in the screenshot that follows, I was trying to install the fio package and run into it.

Error: Failed to Download Metadata for Repo 'AppStream'

Error: Failed to Download Metadata for Repo ‘AppStream’

What is the Cause of This Error?

You may well be aware that CentOS Linux 8 died a premature death, it reached the End Of Life (EOL) on December 31st, 2021, thus it no longer receives development resources from the official CentOS project.

This means that after Dec 31st, 2021, to update your CentOS installation, you are required to change the mirrors to CentOS Vault Mirror, where they will be archived permanently.

Fix Error: Failed to Download Metadata for Repo ‘AppStream’

To fix the above error, open your terminal or login via ssh, and run the following commands to change the repo URL to point to vault.centos.org, from the official CentOS repos.

Here we use the sed command to edit the required directives or parameters in the repo configuration files:

# sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
# sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*

Alternatively, you can also point to the Cloudflare-based vault repository, by running the following commands:

# sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-Linux-*
# sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.epel.cloud|g' /etc/yum.repos.d/CentOS-Linux-*

Now you should be able to update CentOS or install packages without any error:

Install Packages in CentOS 8

Install Packages in CentOS 8

If you wish to migrate from CentOS 8 to Rock Linux 8 or AlamLinux 8, check these guides:

  • How to Migrate from CentOS 8 to Rocky Linux 8
  • How to Migrate from CentOS 8 to AlmaLinux 8.5

That’s all! We hope that this guide helped you fix the above-aforementioned error. Use the comment form below to share feedback with us, you can ask questions as well.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

In this article, I will take you through the steps to solve "Failed to download metadata for repo AppStream" error which I was getting in my CentOS 8 Server while trying to update it using dnf update command. This problem can be encountered in any of the CentOS 8 system which is still in use post December 31st, 2021. The reason is because CentOS 8 had already reached its End of Life(EOL) on this date which means that it will no longer receive any development updates from official CentOS Project.

But if you are still thinking to use or already using this OS after Dec 31st, 2021 due to any reason then you need to change the mirror to Vault where it will be archived permanently like it happened for other older CentOS versions. I am sure many of you are still using CentOS 8 system so probably you might be facing the same issue so I thought to create an article about this so that it will help you guys also.

Solved "Failed to download metadata for repo AppStream"

Also Read: How to Install and Use balenaEtcher on Debian 11 (Bullseye)

So when I tried to update my CentOS 8 Server using dnf update command then I end up having below Failed to download metadata for repo 'AppStream' error.

NOTE:

Please note that here I am using root user to run all the below commands. You can use any user with sudo access to run all these commands. For more information Please check Step by Step: How to Add User to Sudoers to provide sudo access to the User.

[root@localhost ~]# dnf update
CentOS-8 - AppStream 35 B/s | 38 B 00:01
Failed to download metadata for repo 'AppStream'
Error: Failed to download metadata for repo 'AppStream'

To fix the above error, we need to change the repo URL pointing from official CentOS URL to vault.centos.org using below commands.

[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
[root@localhost yum.repos.d]# sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*

Once the mirror is changed and updated, we can now try to update again by using dnf update command as shown below. This time it works fine as expected. Alternatively, we can also think of migrating CentOS 8 to CentOS 8 Stream to get rid of problems like this.

[root@localhost ~]# dnf update
Last metadata expiration check: 0:03:09 ago on Thu 05 May 2022 11:27:35 PM EDT.
Dependencies resolved.
=============================================================================================================================================================
Package Architecture Version Repository Size
=============================================================================================================================================================
Installing:
centos-linux-release noarch 8.5-1.2111.el8 BaseOS 22 k
replacing centos-release.x86_64 8.1-1.1911.0.8.el8
replacing centos-repos.x86_64 8.1-1.1911.0.8.el8
kernel x86_64 4.18.0-348.7.1.el8_5 BaseOS 7.0 M
kernel-core x86_64 4.18.0-348.7.1.el8_5 BaseOS 38 M
kernel-modules x86_64 4.18.0-348.7.1.el8_5 BaseOS 30 M
Upgrading:
PackageKit x86_64 1.1.12-6.el8 AppStream 599 k
......................................................

Hopefully, this will help you solve Failed to download metadata for repo AppStream error. Please let me know your feedback in the comment box.

I had installed a minimalist CentOS 8 on one of my servers. Installation went successful, however, when I tried to update the system using yum update I see this error message: Failed to download metadata for repo. Below is the complete error.

[root@autocontroller ~]# yum update
CentOS-8 - AppStream 70 B/s | 38 B 00:00
Error: Failed to download metadata for repo 'AppStream': Cannot prepare internal mirrorlist: No URLs in mirrorlist

Output from the /var/log/dnf.log for more DEBUG information:

2022-02-02T11:39:36Z DEBUG error: Curl error (6): Couldn't resolve host name for http://mirrorlist.centos.org/?release=8&arch=x86_64&repo=AppStream&infra=stock [Could not resolve host: mirrorlist.centos.org] (http://mirrorlist.centos.org/?release=8&arch=x86_64&repo=AppStream&infra=stock).
2022-02-02T11:39:36Z WARNING Errors during downloading metadata for repository 'AppStream':
- Curl error (6): Couldn't resolve host name for http://mirrorlist.centos.org/?release=8&arch=x86_64&repo=AppStream&infra=stock [Could not resolve host: mirrorlist.centos.org]
2022-02-02T11:39:36Z DDEBUG Cleaning up.
2022-02-02T11:39:36Z SUBDEBUG
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/dnf/repo.py", line 573, in load
ret = self._repo.load()
File "/usr/lib64/python3.6/site-packages/libdnf/repo.py", line 394, in load
return _repo.Repo_load(self)
RuntimeError: Failed to download metadata for repo 'AppStream': Cannot prepare internal mirrorlist: Curl error (6): Couldn't resolve host name for http://mirrorlist.centos.org/?release=8&arch=x86_64&repo=AppStream&infra=stock [Could not resolve host: mirrorlist.centos.org]

But, then verified with the internet connection and DNS and it works just fine as below:

[root@autocontroller ~]# ping google.com
PING google.com (172.217.166.206) 56(84) bytes of data.
64 bytes from del03s13-in-f14.1e100.net (172.217.166.206): icmp_seq=1 ttl=115 ti me=43.5 ms
--- google.com ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 43.508/43.508/43.508/0.000 ms

So how did I fix the issue? Here it is.

CentOS Linux 8 had reached the End Of Life (EOL) on December 31st, 2021. It means that CentOS 8 will no longer receive development resources from the official CentOS project. After Dec 31st, 2021, if you need to update your CentOS, you need to change the mirrors to vault.centos.org where they will be archived permanently. Alternatively, you may want to upgrade to CentOS Stream.

Step 1: Go to the /etc/yum.repos.d/ directory.

[root@autocontroller ~]# cd /etc/yum.repos.d/

Step 2: Run the below commands

[root@autocontroller ~]# sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
[root@autocontroller ~]# sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*

Step 3: Now run the yum update

[root@autocontroller ~]# yum update -y

That’s it!

Author Profile

Ramya Santhosh

is a Web Designer and content creator. A freelance writer on latest trends in technology, gadget reviews, How to’s and many more.

In my case, which is really exceptional, the location of the XML file which contains the repo information is changed.

  • I have Internet connection (ping 8.8.8.8 works)
  • When I run yum upgrade, after a lot of 404 error, I can get the names of packages I must download, but I cannot download them.

And, when I browse into the first 404 repo URL, which is:

http://mirror.airenetworks.es/CentOS/7.4.1708/os/x86_64/repodata/repomd.xml

and I see it absent. Going to its parent folder http://mirror.airenetworks.es/CentOS/7.4.1708/readme I get this:

This directory (and version of CentOS) is deprecated. For normal users,
you should use /7/ and not /7.4.1708/ in your path. Please see this FAQ
concerning the CentOS release scheme:

https://wiki.centos.org/FAQ/General

If you know what you are doing, and absolutely want to remain at the 7.4.1708
level, go to http://vault.centos.org/ for packages.

Please keep in mind that 7.4.1708 no longer gets any updates, nor
any security fix’s.

So, I have to go back to /etc/yum.repo.d to edit the files.

I have:

[base]
name=CentOS-$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#released updates
[updates]
name=CentOS-$releasever - Updates
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

I suspect that $releasever is no more in use, so I can test by changing it to 7:(remember to escape & with )

curl http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=arch

we can get a list of files:

ftp://ftp.cesca.cat/centos/7.5.1804/os/x86_64/
http://ftp.rediris.es/mirror/CentOS/7.5.1804/os/x86_64/
http://ftp.cica.es/CentOS/7.5.1804/os/x86_64/
http://centos.mirror.minorisa.net/7.5.1804/os/x86_64/
http://repo.nixval.com/CentOS/7.5.1804/os/x86_64/
http://centos.uvigo.es/7.5.1804/os/x86_64/
http://ftp.uma.es/mirror/CentOS/7.5.1804/os/x86_64/
http://ftp.cixug.es/CentOS/7.5.1804/os/x86_64/
http://mirror.airenetworks.es/CentOS/7.5.1804/os/x86_64/
http://mirror.gadix.com/centos/7.5.1804/os/x86_64/

So, we can set the variable like this:

  1. Open the /etc/yum.repo.d/CentOS-Base.repo
  2. In the [base] section, define: releasever=7.
  3. Re-run yum upgrade or yum install xxx.

Понравилась статья? Поделить с друзьями:
  • Ошибка не удалось загрузить изображение япикс
  • Ошибка неверный домен ключа что это значит
  • Ошибка не удалось загрузить изображение вконтакте
  • Ошибка неверный домен ключа конфиденциальность условия использования
  • Ошибка не удалось завершить транзакцию