Resolving “Failed to download metadata for repo ‘AppStream'” Error on CentOS 8: DNS and Repository Fixes


5 views

The error message clearly indicates a DNS resolution failure when trying to access mirrorlist.centos.org. This is a common issue with fresh CentOS 8 installations where either:

  • DNS isn't properly configured
  • The default CentOS 8 repositories are outdated (since CentOS 8 reached EOL)
  • Network connectivity issues exist

Before touching repository configurations, verify basic network access:

ping -c 4 google.com
curl -I https://google.com
nslookup mirrorlist.centos.org

If these fail, check your /etc/resolv.conf:

cat /etc/resolv.conf
# Should contain valid nameservers like:
nameserver 8.8.8.8
nameserver 8.8.4.4

Since CentOS 8 is EOL, we need to switch to vault.centos.org:

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

For ongoing updates, consider migrating to CentOS Stream:

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

After making changes, always clear the cache:

sudo dnf clean all
sudo rm -rf /var/cache/dnf
sudo dnf makecache

Test the repository access:

sudo dnf repolist
sudo dnf update

You should now see the repository metadata downloading properly.

While you've opened port 80, also ensure outbound connections aren't blocked:

sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload

When running yum update or attempting package installations on a fresh CentOS 8 system, you might encounter this frustrating error:

Failed to download metadata for repo 'AppStream'
Error: Failed to download metadata for repo 'AppStream'

The key diagnostic clue appears in the DNF log:

2020-03-30T19:33:02Z DEBUG error: Curl error (6): Couldn't resolve host name for http://mirrorlist.centos.org 
[Could not resolve host: mirrorlist.centos.org]

This typically indicates one of three fundamental issues:

  • DNS resolution failure (most common)
  • Mirrorlist service unavailability
  • Network connectivity problems

1. Verify Basic Network Connectivity

First, confirm your system can reach external networks:

ping -c 4 8.8.8.8
curl -Iv https://google.com

If these fail, check your network configuration:

nmcli connection show
ip addr show

2. Fix DNS Resolution

The most common solution is configuring proper DNS servers. Edit the resolv.conf file:

sudo vi /etc/resolv.conf

Add reliable DNS servers (like Google's or Cloudflare's):

nameserver 8.8.8.8
nameserver 1.1.1.1

Make the changes persistent (for NetworkManager systems):

sudo vi /etc/NetworkManager/NetworkManager.conf
# Add under [main]:
dns=default

3. Manual Repository Configuration

If DNS isn't the issue, try using specific mirrors instead of the mirrorlist:

sudo vi /etc/yum.repos.d/CentOS-AppStream.repo

Replace the mirrorlist line with:

baseurl=http://mirror.centos.org/centos/$releasever/AppStream/$basearch/os/

Or use a specific regional mirror:

baseurl=http://mirror.rackspace.com/centos/$releasever/AppStream/$basearch/os/

4. Alternative: Vault CentOS Repositories

For EOL CentOS versions, use the vault:

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

After making changes:

sudo dnf clean all
sudo dnf makecache
sudo dnf update

If issues persist, check these potential culprits:

# Check SELinux status
getenforce

# Verify time synchronization
timedatectl status

# Test repository access directly
curl -v http://mirror.centos.org/centos/8/AppStream/x86_64/os/repodata/repomd.xml

For corporate environments behind proxies:

sudo vi /etc/dnf/dnf.conf
# Add:
proxy=http://proxy.example.com:8080