Failed to synchronize cache for repos for RHEL 8

Latest response

When I run dnf repolist on rhel 8 enabled machine I see the following error "Failed to synchronize cache for repo" as seen below:

dnf repolist

Updating Subscription Management repositories.
Red Hat Enterprise Linux 8 for x86_64 - AppStream (RPMs) 649 B/s | 224 B 00:00
Red Hat Enterprise Linux 8 for x86_64 - BaseOS (RPMs) 635 B/s | 224 B 00:00
Red Hat Enterprise Linux 8 for x86_64 - Supplementary (RPMs) 623 B/s | 224 B 00:00

Failed to synchronize cache for repo 'rhel-8-for-x86_64-appstream-rpms', ignoring this repo.
Failed to synchronize cache for repo 'rhel-8-for-x86_64-baseos-rpms', ignoring this repo.
Failed to synchronize cache for repo 'rhel-8-for-x86_64-supplementary-rpms', ignoring this repo.

Responses

Hi Harsha,

Please execute the following commands ... this should solve the problem. :)

sudo dnf clean all
sudo rm -r /var/cache/dnf
sudo dnf upgrade

Regards,
Christian

Hi Christian,

Thank you for the response. I have tried these commands before, I still have the same issues. I don't have any issues when I am using rhel 8 beta repos but with the usual rhel 8 repos, I see this issue.

Red Hat Enterprise Linux 8 for x86_64 - AppStre Red Hat Enterprise Linux 8 for x86_64 - BaseOS
Red Hat Enterprise Linux 8 for x86_64 - Supplem

I am on Red Hat Satellite 6.3.0. Please let me know if there are any other ways to solve this issue.

Looks like it was not issues with the dnf cache. I think I used 8.0 repos instead of 8 and refreshed manifest, it fixed the issue.

Hi Harsha,

Glad you could get it done ! :)

Regards,
Christian

sudo dnf rm -r /var/cache/dnf should be:

sudo rm -r /var/cache/dnf

Hi Karsten,

Why that ? It works perfectly fine without the force option. The force option should only be
used in rare cases when the remove command otherwise doesn't succeed. It is a dangerous
option which often causes users having a broken system afterwards when they accidentally
made a typo. I'm astonished to see, that a Red Hat employee provides it on the community
portal where many new and not so experienced users are around.

Regards,
Christian

Hi Christian,

thanks for the hint.

First: 'sudo dnf rm -r /var/cache/dnf' contains 'dnf' which is wrong.

Second (-f): Valid point. Preventing users from hitting [enter] after entering '/' could cause disasters. Just copied it from my terminal (repeating the confirmations in this case was quite tedious to me).

Changed my comment.

B.t.w. I could not use this article to solve my problem which is described here: https://access.redhat.com/solutions/4173841 => unfortunately, I couldn't get a valid CA for cdn.redhat.com...

Thank you Karsten, for pointing me to the mistake I made (I accidentally typed dnf, which of
course is wrong). I've corrected it at once to sudo rm -r /var/cache/dnf. Thanks again.
I am glad you agree with me regarding the force option. Now I wish you a great weekend ! :)

Regards,
Christian

Additional Packages 129 MB/s | 5.6 MB 00:00
Failed to download metadata for repo 'AppStream'

Error: Failed to download metadata for repo 'AppStream'

I got again and again same error after followed above step like:

is there anyone who can resolve this issue?

clean all rm -r /var/cache/dnf dnf upgrade

and also

rm -r /var/cache/dnf

not work it work as #rm -rf /var/cache/dnf

whatever solution is given over here no one solution is resolving the issue.

Could you please open a support case, then? And ideally provide sosreport from the client system and Satellite. From top of my head I dont see reason why this won't work, maybe some specific dnf or rhsm config (proxy? I doubt it can affect..).

Im getting this same problem and have tried clearing the cache as suggested but didnt fix. Running with -v switch gives the further error details of :

Cannot download 'https://cdn.redhat.com/content/dist/rhel8/8/x86_64/appstream/os': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried. Error: Failed to synchronize cache for repo 'rhel-8-for-x86_64-appstream-rpms'

System was updating fine until today and is a fresh install of RH and registered with developer subscription.

UPDATE - actually this turned out to be a DNS issue, for some reason my dns config had messed up, once fixed things worked again.

cd /etc/yum.repos.d
rm -rf *.*
yum upgrade
yum update

After searching hundreds of blogs and post not find my solution then I have taken above actions and these fix my all problem.

Hi Sanjeev,

Curious ... are you really sure that removing all repositories indeed does "fix all problems" ??? :D :D :D

Regards,
Christian

Deleting all the repositories isn't quite as disastrous as it sounds as redhat.repo seems to regenerate itself on the next yum run, though I expect any other repositories will stay lost.

Hi Michael,

Mainly I wanted to point out that users should carefully double-check before removing stuff. :)
We see more and more suggestions to 'rm -rf /this-and-that'. Without having a system backup,
this may lead to destruction of the system, which makes a reinstall being the only left solution.

Regards,
Christian

Hey, the above command removed all your repos. Please be careful when you type any command with sudo permission. Now you can't update your system unless you add those repos back again. Please enable themback again. The issue is temporary, I faced same issue, after few hours that is resolved.

rm -rf /

solved all my problems

Hi James,

Great "Friday joke" ... hahaha ... of course it "solved all your problems" - you've deleted the whole system ! :D :D :D

Regards,
Christian

So, what did we learn today ?

If you experience problems with your system - delete it ... and your problem is solved !
Cool, isn't it ? This should make it to the top of the list for troubleshooting instructions.

Absolutely amazing ! :D :D :D

I would like to see the output of your command :) rm -rf will remove all files and folder recursively. As directory structure starts from "/". I will remove all files and folder top of it. In simple term it will delete everything on that partition where your operating system is

Actually the output (on a container and yes I did check I really was in the container before running it) for /bin/rm -rf / is

rm: it is dangerous to operate recursively on '/'
rm: use --no-preserve-root to override this failsafe

It looks like someone thought people might try to do silly things.

Nice warning, Michael - right ? If you burn down your house you don't get something like that ... :)

Regards,
Christian

I had the same errormessage when trying to install packages and having a repo-config file with a "baseurl" pointing to a non-existent path. After fixing the path to point to the existing repo, the error message was gone.

[root@server1 ~]# yum install dnf-automatic
CentOS-8-appstream                                                                      6.9 MB/s | 7.7 MB     00:01
CentOS-8-stuff                                                                                  220  B/s | 224  B     00:01
Error: Failed to synchronize cache for repo 'CentOS-8-stuff'
[root@server1 ~]#

Fixed by just setting the release in subscription manager.

After observing this in /var/log/dnf.log, content/dist/rhel8/8.1/x86_64/appstream/os': Cannot download repomd.xml: Cannot download repodata/ repomd.xml: All mirrors were tried.

where repodata was not found within 8.1 as the location does not exist.

# subscription-manager release --show
Release not set

# subscription-manager release --set 8
Release set to: 8

# dnf clean all
Updating Subscription Management repositories.
16 files removed

# dnf repolist
Updating Subscription Management repositories.
ansible-2.8-for-rhel-8-x86_64-rpms
rhel-8-for-x86_64-appstream-rpms
rhel-8-for-x86_64-baseos-rpms
rhel-8-for-x86_64-supplementary-rpms
satellite-tools-6.6-for-rhel-8-x86_64-rpms

This is what did it for me. Why isn't subscription-manager release --set in the subscription docs when describing how to get a machine up and working?

Thanks for the info Gagandeep, setting the RH release version solved the problem.

This worked for me.

I set the release to the same version according to /etc/redhat-release.

That was 8.1 for me.

However, why must one set the release number? - shouldn't the system know which release you've got installed?

What happens when I've upgraded to a newer version of RHEL8?

Thank you for sharing this Gagandeep, it was shocking to see the Release set to 7.6 on my fresh install of RHEL 8.1

Fixed :- 1st Remove "AppStream" & "BaseOS". & recopying the same folder to same location. after that

yum clean all & yum repolist

problem resolved Enjoy :)

Hi, I have the same issue .I have tried various solutions but still the issue persists.I am running it on VM.Is there any chance a complete reinstallation will resolve the issue?

I've attempted many of the suggestions indicated above. Unfortunately, none of them have fully worked. Some methods brought partial success, but it always ends the same way. Somewhere in the process it kicks out after reporting "Error: Failed to download metadata for repo 'rhel-8-for-x86_64-appstream-e4s-debug-rpms'". Now it's 'appstream'; earlier it was 'satellite-tools-6.6'. I've been at this for a few days now, and I believe my next step is going to be to revert back to an earlier snapshot that I created of the VM prior to doing something which seems to have caused a conflict. My choice is to either go that route, or else just scrap the whole thing and start with a new VM. I prefer the snapshot option because I need to verify that the RHEL 8 template I created in vSphere (Content Library) is at least valid. Tired of playing hit and miss. I'll keep y'all posted.

For me, the issue seems to be that DNF doesn't comply with the yum workaround for disabling a proxy

If the .repo has the following set to disable the proxy : proxy=none

I get

Cannot download 'https://../epel/7/x86_64': Cannot download repomd.xml: Curl error (5): Couldn't resolve proxy name for https://../epel/7/x86_64/repodata/repomd.xml [Could not resolve proxy: none; Unknown error]. Failed to synchronize cache for repo 'EPEL', ignoring this repo. Last metadata expiration check: 0:00:01 ago on Fri 06 Mar 2020 02:55:07 PM AEST.

Is there a known workaround

It sounds like something may have gotten messed up with your dnf variables.

Try: dnf update -y --releasever=8

I had the same original problem : Failed to synchronize cache for repos

I discovered the real problem by doing this: yum update -v

Upon checking the output, I saw some very familiar output. Cannot download repomd.xml: Cannot download repodata/repomd.xml

This is indicative of repo_gpgcheck being enabled.

I fix the issue by adding the following line to /etc/yum.conf: repo_gpgcheck=0

If a repo isn't signed, repo_gpgcheck will cause issues every time.

This was a fresh install of RHEL 8.0.

None of the suggestions given here worked for me, what did work for me is:

[root@rhel8test ~]# subscription-manager refresh
1 local certificate has been deleted.
All local data refreshed

I was then able to update without this error..