Failed to download metadata for repo ‘AppStream’ [CentOS]
I got the above error when I tried to run “yum update”. Below is the complete error. I got this error on centos-8.
[root@hostname ~]# 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
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]
I have followed the below steps to fix the issue.
Step:1:- Go to the /etc/yum.repos.d/
directory.
[root@hostname ~]# cd /etc/yum.repos.d/
Step:2:- Run the below commands
[root@hostname ~]# sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
[root@hostname ~]# sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*
Step:3:- Now run the yum update
[root@hostname ~]# yum update -y
After this issue was resolved.