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

13,133

If you don't already have it, you'll need the gpg keys:

wget 'http://mirror.centos.org/centos/8-stream/BaseOS/x86_64/os/Packages/centos-gpg-keys-8-3.el8.noarch.rpm'
sudo rpm -i 'centos-gpg-keys-8-3.el8.noarch.rpm'

Then it's as simple as transitioning like so:

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

Don't worry -- it doesn't remove any repos, it simply temporarily ignores all of yours, and downloads information regarding the new mirrors.

You may at this point want to actually upgrade your packages:

sudo dnf distro-sync

You'll now be able to use "yum" as usual.

Share:
13,133
Yusuf
Author by

Yusuf

Updated on June 13, 2022

Comments

  • Yusuf
    Yusuf almost 2 years

    I am trying to download java using yum on centOs which I specified in Dockerfile. After pulling centOs image the run crushed and throw this error!? also to mention that my server instance is AWS EC2!

    Step 2/9 : RUN yum install java -y
     ---> Running in 39fc233aa965
    CentOS Linux 8 - AppStream                      184  B/s |  38  B     00:00
    Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist
    The command '/bin/sh -c yum install java -y' returned a non-zero code: 1