In this article, we’ll get to know, how to fix the error, “Failed to download metadata for repo AppStream” in CentOS 8.
For example, you have installed a minimalist CentOS 8 on one of the servers. The entire process of installation goes smoothly and is successful.
But, while updating the system, using the yum update, you’re likely to get the error message, “Failed to download metadata for repo”
Here is the error you’ll get:
[root@server ~]# yum update CentOS-8 - AppStream 70 B/s | 38 B 00:00 Error: Failed to download metadata for repo 'AppStream': Cannot prepare internal mirrorlist: No URLs in mirrorlist
Now the output from the /var/log/dnf.log for more debug information:
2022-02-02T11:39:36Z DEBUG error: Curl error (6): Couldn't resolve host name for http://mirrorlist.centos.org/?release=8&arch=x86_64&repo=AppStream&infra=stock [Could not resolve host: mirrorlist.centos.org] (http://mirrorlist.centos.org/?release=8&arch=x86_64&repo=AppStream&infra=stock). 2022-02-02T11:39:36Z WARNING Errors during downloading metadata for repository 'AppStream': - Curl error (6): Couldn't resolve host name for http://mirrorlist.centos.org/?release=8&arch=x86_64&repo=AppStream&infra=stock [Could not resolve host: mirrorlist.centos.org] 2022-02-02T11:39:36Z DDEBUG Cleaning up. 2022-02-02T11:39:36Z SUBDEBUG Traceback (most recent call last): File "/usr/lib/python3.6/site-packages/dnf/repo.py", line 573, in load ret = self._repo.load() File "/usr/lib64/python3.6/site-packages/libdnf/repo.py", line 394, in load return _repo.Repo_load(self) RuntimeError: Failed to download metadata for repo 'AppStream': Cannot prepare internal mirrorlist: Curl error (6): Couldn't resolve host name for http://mirrorlist.centos.org/?release=8&arch=x86_64&repo=AppStream&infra=stock [Could not resolve host: mirrorlist.centos.org]
If you verify the internet connection and DNS, it works alright as given below:
[root@server ~]# ping google.com PING google.com (172.217.166.206) 56(84) bytes of data. 64 bytes from del03s13-in-f14.1e100.net (172.217.166.206): icmp_seq=1 ttl=115 ti me=43.5 ms --- google.com ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 43.508/43.508/43.508/0.000 ms
Now, how to fix this issue? Let’s see in the below steps:
Fixing The Error: Failed To Download MetaData For Repo
On 31st December 2021, CentOS Linux 9 had reached its End of Life (EOL). This means, it will not receive any development updates from the official CentOS project. Thereafter, 31st December 2021, for updating your CentOS, you will first need to change the mirrors to vault.centos.org. Here they will be archived for all time. Instead, you may also need to upgrade to CentOS stream.
Here are the steps:
Step 1: First go to the /etc/yum.repos.d/ directory.
[root@server ~]# cd /etc/yum.repos.d/
Now, run the commands given below:
[root@server ~]# sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
[root@server ~]# sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*
Step 3: After this, run the yum update:
[root@server ~]# yum update -y
And that’s all!
By following the above steps, you can easily fix the error, “Failed to Download Metadata for Repo ‘AppStream’.