Failed to download metadata for repo ‘AppStream’ [CentOS]

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.

Fix Failed to download metadata for repo

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?

Related Articles

Comments Leave a Comment

  1. This worked. Thank you. Busy testing Proxmox, and deployed a CentOS container but couldn’t update it.

  2. Goto your /etc/yum.repo.d/ directory. And then modify your OS-AppStream.repo & OS-BaseOS.repo by activating instead of .

  3. but still an issue with Remi after this: Problem: cannot install the best update candidate for package remi-release-8.4-1.el8.remi.noarch

  4. straight to the point, fixed a wrong distro repo added previously by using RedHat instead of Centos 8

  5. even these methods are not working when i run the “yum update -y” command it shows failed trying other mirror and still doen’t work

  6. Thank you very much! so helpful for me! I have solved my problem thank for you.

  7. many thanks you save me to spent time to fix it. You are the best 🙂

  8. Many thanks for this, was struggling to update and switch to CentOS Stream until I found this.

  9. NAH MANNN i followed all ur steps and i got the same error 🙁

  10. works like a charm. Why does centos/redhat make these things so difficult.

  11. very helpful. But the question remains: Why do they make these updates so difficult

  12. hi,

    please.. which difference is between
    sed -i ‘s/
    sed -i ‘s|

    thanks 🙂

    1. If the search object (or replacement object) contain / as in the 2nd search object then / can’t be used as object delimiter hence the use of | instead

  13. After executing the steps that you have provided, I still get the same error…

    CentOS Linux 8 – AppStream 23 B/s | 38 B 00:01
    Error: Failed to download metadata for repo ‘appstream’: Cannot prepare internal mirrorlist: No URLs in mirrorlist
    The command ‘/bin/sh -c yum update -y’ returned a non-zero code: 1

      1. I figured out that after you run ‘yum update’ you need to re-run these 3 commands:

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

        This worked for me.

      1. [root@ip-172-31-34-89 yum.repos.d]# sed -i ‘s/^baseurl=http:/baseurl=https/’ CentOS-*
        [root@ip-172-31-34-89 yum.repos.d]# egrep ^baseurl CentOS-*
        CentOS-AppStream.repo:baseurl=https//vault.centos.org/centos/8/AppStream/x86_64/os/
        CentOS-Base.repo:baseurl=https//vault.centos.org/centos/8/BaseOS/x86_64/os/
        CentOS-Extras.repo:baseurl=https//vault.centos.org/centos/8/extras/x86_64/os/
        CentOS-PowerTools.repo:baseurl=https//vault.centos.org/centos/8/PowerTools/x86_64/os/
        [root@ip-172-31-34-89 yum.repos.d]# yum update -y
        Updating Subscription Management repositories.
        Unable to read consumer identity

        This system is not registered with an entitlement server. You can use subscription-manager to register.

        CentOS-8 – AppStream 0.0 B/s | 0 B 00:00
        Error: Failed to download metadata for repo ‘AppStream’: Cannot download repomd.xml: Empty mirrorlist and no basepath specified!

        1. Step 1: Try removing the cache using the below commands:
          rm -rfv /var/cache/yum/*
          yum clean all
          Step 2: Disable the subscription manager
          vim /etc/yum/pluginconf.d/subscription-manager.conf
          enabled=0

      2. [root@ip-172-31-34-89 yum.repos.d]# sed -i ‘s/\$contentdir/centos/’ CentOS-*
        [root@ip-172-31-34-89 yum.repos.d]# yum update
        Updating Subscription Management repositories.
        Unable to read consumer identity

        This system is not registered with an entitlement server. You can use subscription-manager to register.

        CentOS-8 – AppStream 59 MB/s | 8.4 MB 00:00
        CentOS-8 – Base 48 MB/s | 4.6 MB 00:00
        CentOS-8 – Extras 294 kB/s | 10 kB 00:00
        CentOS-8 – PowerTools 29 MB/s | 2.3 MB 00:00
        Dependencies resolved.
        Nothing to do.
        Complete!

        So… Fixed? Thanks

  14. Sorry this solution is not working, pls send me right solution

  15. sed: can’t read /etc/yum.repos.d/CentoOS-*: No such file or directory

  16. Hello, I’ve created a virtual machine and I had the same issue but the is: sed: couldn’t open temporary file /etc/yum.repos.d/sedhZ7EUE: Permission denied.
    How can I get the permission?

  17. Sooperb information. I have encounter this issue when i try to install autofs utility. Now my issue is resolved. Thank you for sharing such beautiful information. –Bilal

  18. Thanks ! Simple, clear and it works ! Exaclaty what I need !

  19. After executing the steps that you have provided, I still get the same error

  20. Muy buen aporte me sirvio mucho gracias (Very good contribution it helped me a lot thank you)

  21. everything was great, the issue was explained and the fix was clear. Tried so many other sites and forums, all talking about the issue but not giving a clear resolution to fixing the repos since the official support ended.

  22. good. i’ve successfully updated my CentOS 8.3 to 8.5 after this repo change.

  23. Following steps above I migrated successfully a CentOS 8 to CentOS Stream 8 in Oracle cloud. Thanks a lot

  24. Thank you for the help. Was trying to upgrade Centos 8.1 to the latest released version/packages in the vault before migrating to Rocky.

  25. HI i am getting same error. [root@c792b3ab5701 /]# cd /etc/yum.repos.d/ [root@c792b3ab5701 yum.repos.d]# sed -i ‘s/mirrorlist/#mirrorlist/g’ /etc/yum.repos.d/CentOS-* [root@c792b3ab5701 yum.repos.d]# sed -i ‘s|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g’ /etc/yum.repos.d/CentOS-* [root@c792b3ab5701 yum.repos.d]# yum update -y Failed to set locale, defaulting to C.UTF-8 CentOS Linux 8 – AppStream 0.0 B/s | 0 B 00:00 Errors during downloading metadata for repository ‘appstream’: – Curl error (60): Peer certificate cannot be authenticated with given CA certificates for https://vault.centos.org/centos/8/AppStream/x86_64/os/repodata/repomd.xml [SSL certificate problem: certificate is not yet valid] Error: Failed to download metadata for repo ‘appstream’: Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried [root@c792b3ab5701 yum.repos.d]#

  26. After applying the suggested changes, I’m still facing the issue

  27. Funcionou corretamente aqui. Obrigado (Portugese) – It worked correctly here. Thanks

  28. Gracias Amiga me salvaste el asterisco 2 horas instalando se ivan al tacho pero con tu magia y tu toque de balon ese futbol picante con 2 o 3 comandos me solucionaste la vida,

  29. Waw, This post really helped me.
    I was looking for solution since 2 days.

    Thank You

  30. Should perhaps also include the alternative of switching to AlmaLinux.

  31. This was a big help, thanks. Unfortunately, while it also fixed the software application in CentOS, that is virtually devoid of applications to install. I don’t know if that’s due to CentOS being all but decommissioned in favor of the newer stream releases, or some other reason. I’ve worked with a lot of commercial UNIX systems (nothing actually fun like Linux), but I installed CentOS 8 just to follow along with a Redhat certification course while I wait for the Redhat Export Hold to be removed from my account (if that ever happens). Thanks again for the help!

  32. This was exactly the article I needed. No recommendations for improvement. Thanks so much!

  33. Merci, problème résolu en quelques minutes grâce à vous !

  34. Isn’t that easier to do?
    Connecting the CentOS Stream repository:
    # dnf install centos-release-stream

    Specify the new repository as default:
    # dnf swap centos-{linux,stream}-repos

    Synchronizing installed packages:
    # dnf distro-sync

  35. # cat /etc/redhat-release
    CentOS Linux release 8.5.2111

    I am ending up below error . Appreciate your support

    yum update -y
    CentOS Linux 8 – AppStream 0.0 B/s | 0 B 00:04
    Errors during downloading metadata for repository ‘appstream’:
    – Curl error (60): Peer certificate cannot be authenticated with given CA certificates for https://vault.centos.org/centos/8/AppStream/x86_64/os/repodata/repomd.xml [SSL certificate problem: self signed certificate in certificate chain]
    Error: Failed to download metadata for repo ‘appstream’: Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried

  36. Great job thank you I ran into this issue today (2/15/22) and your steps worked perfectly.

  37. This solution worked like charm . But when tried after few days on same CentOS 8.0 , I get below Error . Did anyone else faced this

    [root@master-node ~]# dnf update -v
    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
    error: Curl error (28): Timeout was reached for https://vault.centos.org/centos/8/AppStream/x86_64/os/repodata/repomd.xml [Operation timed out after 30000 milliseconds with 0 out of 0 bytes received] (https://vault.centos.org/centos/8/AppStream/x86_64/os/repodata/repomd.xml).
    CentOS-8 – AppStream 0.0 B/s | 0 B 00:52
    Cannot download ‘http://vault.centos.org/centos/8/AppStream/x86_64/os/’: Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried.
    Failed to download metadata for repo ‘AppStream’
    Error: Failed to download metadata for repo ‘AppStream’

    1. I am getting the same error. Were you able to get it resolved ?

  38. Finally someone telling us what to do instead of sending us towards a blind alley like most are doing on stackoverflow. Thanks mate!

  39. thx, I already wondered why ‘yum update’ no longer wordked.

  40. Thanks for saving my time!. I was going to install centos 8.5.

  41. Thank you for the sed commands to rewire the repos to the vault. What a time saver.

  42. Tks Ramya! Your article was indeed helpful to solve my problem.

  43. Hero of the night. Works as intended.

    CentOS only needs to make it couple more days now until Debian makes a return to my machines. But the update(s) could not wait.

  44. Thanks a lot. That helped me a lot. and makes me be sure to migrate to another OS, based on CentOS (Rocky??)

  45. Clear and concise. What the problem was; why it occurred; what to do. Thanks!

    1. I take it back. cat /etc/centos-release shows 8.5.2111. I’m guessing I won’t need this fix when I actually get Stream 8 installed correctly. -jcr

Leave a Comment