CentOS/AlmaLinux Error: Failed to download metadata for repo 'appstream'
Cause
This error typically appears on CentOS 8 because the CentOS 8 project reached End of Life on December 31, 2021. Official mirrors no longer exist.
Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist:
No URLs in mirrorlist
Solution for CentOS 8 (EOL)
Option 1: migrate to AlmaLinux 8 (recommended)
AlmaLinux 8 is the official replacement, binary compatible with CentOS 8:
# Install migration tool
curl -O https://raw.githubusercontent.com/AlmaLinux/almalinux-deploy/master/almalinux-deploy.sh
chmod +x almalinux-deploy.sh
sudo bash almalinux-deploy.sh
# Restart
sudo reboot
# Verify
cat /etc/almalinux-release
Option 2: use vaults (only for temporary updates)
If you can't migrate yet, redirect to archive vault:
# Replace mirrors with CentOS vaults
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-*
# Update
sudo dnf update -y
Solution for CentOS 7 (EOL since June 30, 2024)
# Redirect to vaults
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-*
# Test
sudo yum update -y
CentOS 7 reached End of Life. It no longer receives security updates. Migrating to AlmaLinux 9 or Rocky Linux 9 is recommended.
Solution for AlmaLinux / Rocky Linux (temporarily unreachable mirrors)
If the problem is temporary (mirror offline):
# Clean yum/dnf cache
sudo dnf clean all
sudo dnf makecache
# Force a specific mirror
sudo dnf update --setopt=fastestmirror=True -y
# Check which repos are enabled
sudo dnf repolist
Disable a problematic repo
# Temporarily disable appstream
sudo dnf update --disablerepo=appstream -y
# Or modify the repo file
sudo nano /etc/yum.repos.d/almalinux-appstream.repo
# Change enabled=1 to enabled=0
Install iptables on CentOS 7 / AlmaLinux
# CentOS 7
sudo yum install iptables-services -y
sudo systemctl start iptables
sudo systemctl enable iptables
# AlmaLinux 8/9 (uses nftables by default, but you can install iptables)
sudo dnf install iptables-services -y
sudo systemctl disable firewalld
sudo systemctl stop firewalld
sudo systemctl start iptables
sudo systemctl enable iptables
# Verify
sudo iptables -L -n
Basic iptables configuration on CentOS/AlmaLinux
# Save current config
sudo service iptables save
# Configuration file
cat /etc/sysconfig/iptables
# Reload rules
sudo systemctl restart iptables
Migrate from CentOS 7 to AlmaLinux 9
Direct migration 7 → 9 is not supported. Recommended path:
See the guide OS Reinstallation to reinstall from panel.
- Make a complete backup of server (VirtFusion snapshot)
- Note all installed packages: rpm -qa > /tmp/packages-centos7.txt
- Reinstall the VPS with AlmaLinux 9 from VirtFusion panel
- Reinstall necessary packages on new system
Related articles
Locked Out of VPS
Complete guide to recover server access when locked out, with step-by-step instructions from VNC Console
Server Unreachable
What to do when server is not responding or you can't connect via SSH
Website Not Reachable
What to do when website is not responding, shows errors, or is unreachable
