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

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