What is this error?
A repository (repo) is an online store of software. Your server downloads programs from it with a tool called dnf or yum. Metadata is the list that tells the server what is in the store.
The error looks like this:
Error: Failed to download metadata for repo 'AppStream': Cannot prepare internal mirrorlist: No URLs in mirrorlist
CentOS 8 reached its end of life. That means it no longer gets updates. Its old mirror addresses were moved, so the server cannot find the list any more.
Before you start
You are going to edit system files. Take a backup or a snapshot of your server first. A backup is a spare copy you can restore if something goes wrong.
Steps
- Log in to your server as root with SSH. SSH is a safe way to type commands on a faraway computer.
- Go to the repo folder:
This moves you into the folder that holds the repo files.cd /etc/yum.repos.d/ - Turn off the dead mirror lists:
This puts ased -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*#in front of the old lines, so the server ignores them. - Point the repo files to the archive address:
The vault is where CentOS keeps its old releases.sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-* - Clean the saved data:
This removes old cached lists.dnf clean all - Build the new list:
This downloads the metadata again. It should finish without an error.dnf makecache
Test it
Run dnf update or install a small program. If it works, the fix is done.
A better long-term choice
The vault only holds old, final files. It gets no security fixes. Think about moving to a supported system, such as CentOS Stream, AlmaLinux or Rocky Linux. Plan this move with care and keep a full backup. Hostvento support can advise you.
Quick recap
- The error comes from CentOS 8 reaching end of life.
- Back up first, then edit the files in
/etc/yum.repos.d/. - Comment out
mirrorlistand pointbaseurltovault.centos.org. - Run
dnf clean allanddnf makecache. - Plan a move to a supported system.