CentOS/AlmaLinux Error: Failed to download metadata for repo 'appstream'

01

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
02

Solution for CentOS 8 (EOL)

Option 1: migrate to AlmaLinux 8 (recommended)

AlmaLinux 8 is the official replacement, binary compatible with CentOS 8:

bash
# 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:

bash
# 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
03

Solution for CentOS 7 (EOL since June 30, 2024)

bash
# 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.

04

Solution for AlmaLinux / Rocky Linux (temporarily unreachable mirrors)

If the problem is temporary (mirror offline):

bash
# 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

bash
# 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
05

Install iptables on CentOS 7 / AlmaLinux

bash
# 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

bash
# Save current config
sudo service iptables save

# Configuration file
cat /etc/sysconfig/iptables

# Reload rules
sudo systemctl restart iptables
06

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

DeluxHost, opgericht in 2023, biedt hoogwaardige hostingoplossingen voor diverse digitale behoeften. Wij bieden gedeelde hosting, VPS en dedicated servers met geavanceerde beveiliging en wereldwijde datacenters.

© DeluxHost, Alle rechten voorbehouden. | BTW-nummer: IT17734661006
Alle systemen operationeel