Progressively un-centoing

I got slightly annoyed when Centos were terminated. In my efforts to Fedorize the server I use everyday to host the WordPress blog that records most of the work done on our Quality Managament System I encountered this annoying error

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

luckily Habibur Rhoman Joy from namespaceit.com provided an easy solution on his blog.

Habibur Rhoman Joy
FROM centos:8<br data-rich-text-line-break="true" /><br data-rich-text-line-break="true" />RUN sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-Linux-* &&\<br data-rich-text-line-break="true" />    sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-Linux-*<br data-rich-text-line-break="true" /><br data-rich-text-line-break="true" />#docker<br data-rich-text-line-break="true" />RUN yum upgrade -y<br data-rich-text-line-break="true" /><br data-rich-text-line-break="true" />#other commands<br data-rich-text-line-break="true" />

 

On Centos 8, I have run “sudo yum update” but getting this error – 

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

Here I have given different solution for different situation.

Solution 1:

This error we are getting cause CentOS 8 became EOL at the end of 2021. Better if you migrate to CentOS Stream 8, CentOS 9 or Rocky Linux.

To solve current os you can run these commands –

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

If you run these commands then dnf will work, but you will not get any updates.

If you want you can also upgrade to centos 8 stream:

 sudo dnf install centos-release-stream -y
 sudo dnf swap centos-{linux,stream}-repos -y
 sudo dnf distro-sync -y

 

Solution 2:

If you are using docker, you may face same type of problem. Hope this commands will help you –

FROM centos:8

RUN 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-*

#docker
RUN yum upgrade -y

#other commands

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.