Errors during downloading metadata for repository 'appstream':

When I tried to run dnf update or yum update commands on Rocky Linux 8.6 I got this errormessage: “Errors during downloading metadata for repository ‘appstream’: Curl error…”
or
“Failed to download metadata for repo ‘appstream’”

I tried to run dnf clean all but the error retained.

I found this article for similar error in CentOS:
https://techglimpse.com/failed-metadata-repo-appstream-centos-8/

I tried to adopt this solution and changed the link to Rocky repo.

Finally I used this solution below and it worked for me:

sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/Rocky-*

sed -i 's|#baseurl=http://dl.rockylinux.org/$contentdir|baseurl=http://dl.rockylinux.org/vault/rocky|g' /etc/yum.repos.d/Rocky-*

The mirror that is close to you may have had some issues. Its better to revert your change to not add load to the primary servers. The mirrorlist is distributing the load for that reason.

In such cases you can do dnf clean all; dnf update or try it again a bit later in the day …

Just to add to what Ritov has already said, I have had the same errors in the past, and just waited till later in day and then things worked. Most likely a temporary connection or server issue.