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

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,9411 gold badge11 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.8k17 gold badges99 silver badges185 bronze badges

answered Apr 4, 2020 at 12:21

Yazan Yahya's user avatar

3

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.8k17 gold badges99 silver badges185 bronze badges

answered Jan 30, 2020 at 20:00

CODE-REaD's user avatar

CODE-REaDCODE-REaD

2,7493 gold badges33 silver badges60 bronze badges

1

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

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

Cody Tookode's user avatar

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,6884 gold badges24 silver badges48 bronze badges

answered May 1, 2020 at 23:51

ICTSOL's user avatar

1

Having great difficulty tracking down what is causing the below error when attempting to update any package from any repo. I have tested multiple repos by setting all others to disabled. I have cleaned all cache and removed any dnf yum cache files.

# dnf -v update
Loaded plugins: builddep, changelog, config-manager, copr, debug, debuginfo-install, download, generate_completion_cache, needs-restarting, playground, repoclosure, repodiff, repograph, repomanage, reposync
DNF version: 4.2.7
cachedir: /var/cache/dnf
repo: downloading from remote: AppStream
error: Curl error (28): Timeout was reached for http://mirrorlist.centos.org/?release=8&arch=x86_64&repo=AppStream&infra=stock [Resolving timed out after 30000 milliseconds] (http://mirrorlist.centos.org/?release=8&arch=x86_64&repo=AppStream&infra=stock).
CentOS-8 - AppStream                                                                                                                                                     0.0  B/s |   0  B     00:30    
Cannot download 'http://mirrorlist.centos.org/?release=8&arch=x86_64&repo=AppStream&infra=stock': Cannot prepare internal mirrorlist: Curl error (28): Timeout was reached for http://mirrorlist.centos.org/?release=8&arch=x86_64&repo=AppStream&infra=stock [Resolving timed out after 30000 milliseconds].
Failed to download metadata for repo 'AppStream'
Error: Failed to download metadata for repo 'AppStream'

Each time I attempt a dnf update, load average on the server goes thru the roof, up to 40x

curl can access the mirror site.

curl 'http://mirrorlist.centos.org/?release=8&arch=x86_64&repo=AppStream&infra=stock'
http://ftp.tc.edu.tw/Linux/CentOS/8.2.2004/AppStream/x86_64/os/
http://mirror.horizon.vn/centos/8.2.2004/AppStream/x86_64/os/
http://ftp.jaist.ac.jp/pub/Linux/CentOS/8.2.2004/AppStream/x86_64/os/
http://centosg9.centos.org/centos/8.2.2004/AppStream/x86_64/os/
http://packet01.centos.org/centos/8.2.2004/AppStream/x86_64/os/
http://mirror.s8.centos.org/centos/8.2.2004/AppStream/x86_64/os/
http://centoso7.centos.org/centos/8.2.2004/AppStream/x86_64/os/
http://centosh9.centos.org/centos/8.2.2004/AppStream/x86_64/os/
http://centosc8.centos.org/centos/8.2.2004/AppStream/x86_64/os/
http://centosg7.centos.org/centos/8.2.2004/AppStream/x86_64/os/

I have also tried using baserurl in .repo, same error

I have also replaced the baseurl with one of the url’s returned by curl, same error

I have tried many suggestions such as yum/dnf error: Failed to download metadata for repo
and similar, none work for me.
Some articles point to bugs in the env vars for $releaseserver etc. I have also tried replacing with actual values. same error.

Internet connection obviously OK due to curl result.
No proxy used.
DNS OK

cat /etc/redhat-release
CentOS Linux release 8.1.1911 (Core)

uname -a
Linux xxxx 4.18.0-147.5.1.el8_1.x86_64 #1 SMP Wed Feb 5 02:00:39 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

Any suggestions would be greatly appreciated.

Перейти к содержанию

На чтение 1 мин Просмотров 3.7к. Опубликовано 3 марта, 2022 Обновлено 3 марта, 2022

При попытке стандартным методом обновить операционную систему Centos 8 получаем следующую фигню:

[root@mail ~]# yum update
CentOS Linux 8 - AppStream                      116  B/s |  38  B     00:00
Ошибка: Не удалось загрузить метаданные для репозитория «appstream»: Cannot prep                            are internal mirrorlist: No URLs in mirrorlist

Не удалось загрузить метаданные для репозитория «appstream»: Cannot prep are internal mirrorlist: No URLs in mirrorlist

Ну что, поздравляю. Centos 8 официально умер 31.12.2021 года.

Чтоб решить проблему с скачиванием нужных пакетов из официальных репозиториев, нужно перенаправить свои репозитории /etc/yum.repos.d/ на http://vault.centos.org вместо http://mirror.centos.org. Делается это следующим образом:

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

Не удалось загрузить метаданные для репозитория «appstream»: Cannot prep are internal mirrorlist: No URLs in mirrorlist

Проверяем:

yum update

Не удалось загрузить метаданные для репозитория «appstream»: Cannot prep are internal mirrorlist: No URLs in mirrorlist

Заработало.

Но!!! Обновление безопасности вы получать не будете. Но вы можете перейти на SentOS Stream, выполнив команды:

dnf --disablerepo '*' --enablerepo extras swap centos-linux-repos centos-stream-repos
dnf distro-sync

После чего выполните перезагрузку

( 7 оценок, среднее 4.43 из 5 )

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,9411 gold badge11 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.8k17 gold badges99 silver badges185 bronze badges

answered Apr 4, 2020 at 12:21

Yazan Yahya's user avatar

3

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.8k17 gold badges99 silver badges185 bronze badges

answered Jan 30, 2020 at 20:00

CODE-REaD's user avatar

CODE-REaDCODE-REaD

2,7493 gold badges33 silver badges60 bronze badges

1

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

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

Cody Tookode's user avatar

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,6884 gold badges24 silver badges48 bronze badges

answered May 1, 2020 at 23:51

ICTSOL's user avatar

1

При попытке обновить или установить пакеты из репозиториев CentOS 8 выдается следующая ошибка: «Ошибка: Не удалось загрузить метаданные для репозитория ?appstream?: Cannot prepare internal mirrorlist: No URLs in mirrorlist«.

На самом деле об этом предупреждали заранее разработчики CentOS, конкретнее от отказа разработки версий ОС и переход на Stream версию, подробнее об этом можно прочитать тут.

Чтоб решить проблему с скачиванием нужных пакетов из официальных репозиториев, нужно перенаправить свои репозитории /etc/yum.repos.d/ на http://vault.centos.org вместо http://mirror.centos.org. Делается это следующим образом:

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

После чего репозитории будут доступны, но вы не будете получать обновления безопасности, т.к. CentOS 8 официально умерла 31.12.21. Но вы можете перейти на SentOS Stream, выполнив следующие команды:

dnf --disablerepo '*' --enablerepo extras swap centos-linux-repos centos-stream-repos
dnf distro-sync

После чего возможно потребуется перезагрузка. Более подробную информацию о переходе на centos strem можно получить тут.

  • Ошибка не удалось загрузить контроллер index
  • Ошибка не удалось загрузить компонент произошла ошибка попробуйте перезагрузить страницу
  • Ошибка не удалось загрузить изображение япикс
  • Ошибка не удалось загрузить изображение вконтакте
  • Ошибка не удалось загрузить документ pdf что делать