Yum on Centos 8 - Failed to download metadata for repo 'AppStream'
Solution 1
Apparently not the problem here, but if you have pinned yourself to CentOS 8.1.1911 you will get the same error until you re-point your /etc/yum.repos.d/ repositories at http://vault.centos.org instead of http://mirror.centos.org
Solution 2
You need to be connected to the Internet in order to download packages.
Check that you have an IP address (with ip a
), that you have a default route (with ip r
), and that you have nameservers defined so you can resolve names (with cat /etc/resolv.conf
).
Solution 3
I got the same error message when installing PHP. It was caused by the network configuration: after changing the gateway address in /etc/sysconfig/network-scripts/ifcfg-enp2s0 the problem was solved. Probably caused by changing from DHCP to a static IP-Address. The information in my internet-router was misleading. I just used the first address in my LAN, in my case: 192.168.11.1. It is the address of the management-console of my router.
Solution 4
In the name of ALLAH. I think that This problem reseon is for End of Life of centos version..
CentOS Linux 7 EOL: 2024-06-30
CentOS Linux 8 EOL: 2021-12-31
CentOS Stream 8 EOL: 2024-05-31
CentOS Stream 9 EOL: estimated 2027, dependent on RHEL9 end of “Full Support Phase”
So I Migrating from CentOS Linux 8 to CentOS Stream.
notice than your server must be fresh. In the operating environment it is associated with risk.
#dnf install centos-release-stream
#dnf swap centos-{linux,stream}-repos
#dnf distro-sync
instruction is in this url: https://www.tecmint.com/migrate-centos-8-to-centos-stream/
Related videos on Youtube
Imag1ne
Updated on September 18, 2022Comments
-
Imag1ne almost 2 years
I'm on a fresh Centos 8 install and have tried to use yum for the first time (on this machine). I get the following for any attempt to install or update anything:
yum update CentOS-8 - AppStream 0.0 B/s | 0 B 00:00 Failed to download metadata for repo 'AppStream' Error: Failed to download metadata for repo 'AppStream'
Port 80 is open although nmap reports it as closed presumably because I haven't yet installed apache. To be double sure I have added port 80 to firewalld which is confirmed:
firewall-cmd --list-ports 25/tcp 80/tcp
I have tried various advice like yum clean and clearing the yum cache but nothing helps.
This is what is in the dnf.log:
2020-03-30T19:33:01Z INFO --- logging initialized --- 2020-03-30T19:33:01Z DDEBUG timer: config: 4 ms 2020-03-30T19:33:01Z DEBUG Loaded plugins: builddep, changelog, config-manager, copr, debug, debuginfo-install, download, generate_completion_cache, needs-restarting, playground, repoclosure, repodiff, repograph, repomanage, reposync 2020-03-30T19:33:01Z DEBUG DNF version: 4.2.7 2020-03-30T19:33:01Z DDEBUG Command: yum install httpd 2020-03-30T19:33:01Z DDEBUG Installroot: / 2020-03-30T19:33:01Z DDEBUG Releasever: 8 2020-03-30T19:33:01Z DEBUG cachedir: /var/cache/dnf 2020-03-30T19:33:01Z DDEBUG Base command: install 2020-03-30T19:33:01Z DDEBUG Extra commands: ['install', 'httpd'] 2020-03-30T19:33:01Z DEBUG repo: downloading from remote: AppStream 2020-03-30T19:33:02Z 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). 2020-03-30T19:33:02Z DEBUG Cannot download 'http://mirrorlist.centos.org/?release=8&arch=x86_64&repo=AppStream&infra=stock': 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]. 2020-03-30T19:33:02Z ERROR Failed to download metadata for repo 'AppStream' 2020-03-30T19:33:02Z DDEBUG Cleaning up. 2020-03-30T19:33:02Z SUBDEBUG Traceback (most recent call last): File "/usr/lib/python3.6/site-packages/dnf/repo.py", line 552, 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' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/lib/python3.6/site-packages/dnf/cli/main.py", line 65, in main return _main(base, args, cli_class, option_parser_class) File "/usr/lib/python3.6/site-packages/dnf/cli/main.py", line 98, in _main return cli_run(cli, base) File "/usr/lib/python3.6/site-packages/dnf/cli/main.py", line 114, in cli_run cli.run() File "/usr/lib/python3.6/site-packages/dnf/cli/cli.py", line 1134, in run self._process_demands() File "/usr/lib/python3.6/site-packages/dnf/cli/cli.py", line 832, in _process_demands load_available_repos=self.demands.available_repos) File "/usr/lib/python3.6/site-packages/dnf/base.py", line 406, in fill_sack self._add_repo_to_sack(r) File "/usr/lib/python3.6/site-packages/dnf/base.py", line 136, in _add_repo_to_sack repo.load() File "/usr/lib/python3.6/site-packages/dnf/repo.py", line 558, in load raise dnf.exceptions.RepoError(str(e)) dnf.exceptions.RepoError: Failed to download metadata for repo 'AppStream' 2020-03-30T19:33:02Z CRITICAL Error: Failed to download metadata for repo 'AppStream'
-
Michael Hampton almost 4 yearsStrange, this got a downvote with no explanation despite the OP saying that it was actually the answer. Why is that?
-
Nick Perkins over 2 yearsProbably for saying "you need the internet to download packages", lol.
-
mordack550 over 2 yearsHow can I do that? That would be very useful
-
dortegaoh over 2 yearsUhm, no. While it is true that CentOS 8 is EOL now, it was not true in March 2020, when the question was asked. This was a different problem.
-
Raven over 2 years@mordack550 I've added a link to my answer that gives an example of pinning. It can be a little tricky, but vault.centos.org is the key.
-
SvennD over 2 yearsI had this issue today, and for me this was the issue; It got resolved by switching to Centos 8 Stream. This can be done :
dnf --disablerepo '*' --enablerepo=extras swap centos-linux-repos centos-stream-repos dnf distro-sync
-
drivard over 2 years@SvennD is right it also worked for me except I had to add a
;
to his command to threat it as 2 commands:dnf --disablerepo '*' --enablerepo=extras swap centos-linux-repos centos-stream-repos; dnf distro-sync
-
Felipe Alameda A over 2 years@drivard Thank you. It works.