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

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

На чтение 1 мин Просмотров 3.5к. Опубликовано 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,9311 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 badges98 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 badges98 silver badges185 bronze badges

answered Jan 30, 2020 at 20:00

CODE-REaD's user avatar

CODE-REaDCODE-REaD

2,7393 gold badges32 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

Al Po's user avatar

Al PoAl Po

84212 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,6884 gold badges24 silver badges47 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 можно получить тут.

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 read this far, tweet to the author to show them you care. Tweet a thanks

Photo of author

Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.


Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Updated on February 10, 2022

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!

Was this article helpful?

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.

Related Articles

Понравилась статья? Поделить с друзьями:
  • Ошибка не удалось загрузить конфигурацию hamachi
  • Ошибка не удалось загрузить контроллер index
  • Ошибка не удалось загрузить изображение япикс
  • Ошибка не удалось загрузить изображение вконтакте
  • Ошибка не удалось загрузить social club