Error failed to synchronize cache for repo updates

This article will help you to resolve the issue synchronize cache for repo 'appstream' when encountered during upgrading CentOS 7 to CentOS 8...

Recently I had explored upgrading CentOS 7 to CentOS 8 and during the process, I encountered the error: Failed to synchronize cache for repo ‘appstream’. Below is the complete error:

Failed to synchronize cache for repo 'baseos', ignoring this repo.
Failed to synchronize cache for repo 'appstream', ignoring this repo.

Output from the /var/log/dnf.log for more DEBUG information:

2022-02-15T10:09:08Z DEBUG repo: downloading from remote: appstream
2022-02-15T10:09:08Z DEBUG Cannot download 'http://mirror.centos.org/centos/8/AppStream/x86_64/os/': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried.
2022-02-15T10:09:08Z DEBUG repo: downloading from remote: extras
2022-02-15T10:09:08Z DEBUG not found other for: CentOS Linux 8 - Extras
2022-02-15T10:09:08Z DEBUG not found modules for: CentOS Linux 8 - Extras
2022-02-15T10:09:08Z DEBUG not found deltainfo for: CentOS Linux 8 - Extras
2022-02-15T10:09:08Z DEBUG not found updateinfo for: CentOS Linux 8 - Extras
2022-02-15T10:09:08Z DEBUG extras: using metadata from Fri 10 Dec 2021 06:26:25 PM IST.
2022-02-15T10:09:08Z WARNING Failed to synchronize cache for repo 'baseos', ignoring this repo.
2022-02-15T10:09:08Z WARNING Failed to synchronize cache for repo 'appstream', ignoring this repo.

Looking at the error message, I thought the issue might be because of the internet connection. However, the internet connection and DNS worked just fine as shown below.

[root@upgrade-centos log]# ping google.com
PING google.com (172.217.166.206) 56(84) bytes of data.
64 bytes from del03s13-in-f14.1e100.net (172.217.166.206): icmp_seq=1 ttl=115 time=44.10 ms
^C
--- google.com ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 44.971/44.971/44.971/0.000 ms

So how did I fix the issue? Here it is.

How to fix Failed to synchronize cache for repo appstream

There could be multiple reasons for this issue. The most common ones are:

  • Incorrect date and time settings
  • Old dnf cache available or expired
  • CentOS baseURL

How to fix Incorrect date and time settings

The timedatectlcommand is a new utility tool in CentOS 7/8. It is a replacement for old traditional date command used in sysvinit daemon-based Linux distributions.

Find the current date and time of your system. Make sure it is correct with the proper time zone.

[root@upgrade-centos ~]# timedatectl
Local time: Tue 2022-02-15 11:24:25 UTC
Universal time: Tue 2022-02-15 11:24:25 UTC
RTC time: Tue 2022-02-15 11:24:25
Time zone: UTC (UTC, +0000)
System clock synchronized: no
NTP service: active
RTC in local TZ: no

Set to your timezone

[root@upgrade-centos ~]# timedatectl set-timezone "Asia/Kolkata"

[root@upgrade-centos ~]# date
Tue Feb 15 16:58:57 IST 2022

How to clear Old/expired dnf cache

Here is an article to clean each kind of cache. To clean all of it, run the below command:

[root@upgrade-centos ~]# dnf clean all
[root@upgrade-centos ~]# rm -rf /var/cache/dnf

How to change CentOS baseURL from mirror.centos.org to vault.centos.org

CentOS Linux 8 had reached the End Of Life (EOL) on December 31st, 2021. It means that CentOS 8 will no longer receive development resources from the official CentOS project. After Dec 31st, 2021, if you need to update your CentOS, you need to change the mirrors to vault.centos.org where they will be archived permanently. Alternatively, you may want to upgrade to CentOS Stream or migrate from CentOS to Rocky Linux.

Go to the /etc/yum.repos.d/ directory.

[root@autocontroller ~]# cd /etc/yum.repos.d/

Run the below commands

[root@autocontroller ~]# sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
[root@autocontroller ~]# sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*

Now run  dnf update

[root@autocontroller ~]# dnf update

That’s it!

Author Profile

Ramya Santhosh

is a Web Designer and content creator. A freelance writer on latest trends in technology, gadget reviews, How to’s and many more.

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.

Harsha Cherukuri's picture

“Failed to synchronize cache for repo” errors when updating Fedora templates

This is general Fedora issue, not a Qubes-specific issue.
Usually, this is due to network problems (especially if downloading updates over Tor) or problems with the download mirrors.
Often, the problem can be resolved by trying again on a different connection (a different Tor circuit, if using Tor) or waiting and trying again later.
Here are some examples of non-Qubes reports about this problem:

  • https://ask.fedoraproject.org/en/question/88086/error-failed-to-synchronize-cache-for-repo-fedora/
  • https://unix.stackexchange.com/questions/390805/repos-not-working-on-fedora-error-failed-to-synchronize-cache-for-repo-update
  • https://www.reddit.com/r/Fedora/comments/74nldq/fedora_26_dnf_error_failed_to_synchronize_cache/
  • https://bugzilla.redhat.com/show_bug.cgi?id=1494178
  • https://stackoverflow.com/questions/45318256/error-failed-to-synchronize-cache-for-repo-updates

More examples can be found by searching for “Failed to synchronize cache for repo” (with quotation marks) on your preferred search engine.

Lost internet access after a template update

In earlier versions of Qubes, there were situations where qubes lost internet access after a template update. The following fix should be applied in recent versions of Qubes.

Run systemctl enable NetworkManager-dispatcher.service in the template upon which your NetVM is based.
You may have to reboot afterward for the change to take effect.
(Note: This is an upstream problem. See this Redhat ticket).
For details, see the qubes-users mailing list threads here and here.)

Windows update is stuck

This has nothing to do with Qubes.
It’s a longstanding Windows bug.
More information about this issue and solutions can be found here.

This can usually be fixed by updating via the command line.

In dom0, open a terminal and run sudo qubes-dom0-update.

Depending on your operating system, open a terminal in the templates and run:

  • Fedora: sudo dnf upgrade
  • Debian: apt-get update && apt-get dist-upgrade

The Problem

While installing package or listing using dnf or yum commands getting below errors:

# dnf repolist
..
Failed to synchronize cache for repo 'xxx', ignoring this repo.
Failed to synchronize cache for repo 'yyy', ignoring this repo.

While checking the dnf logs:

# tail -f /var/log/dnf.log
2019-08-12T10:58:13Z INFO --- logging initialized ---
2019-08-12T10:58:13Z DDEBUG timer: config: 3 ms
2019-08-12T10:58:13Z DEBUG Loaded plugins: builddep, changelog, config-manager, copr, debug, debuginfo-install, download, generate_completion_cache, needs-restarting, playground, repoclosure, repodiff, repograph, repomanage, reposync
2019-08-12T10:58:13Z DEBUG DNF version: 4.0.9
2019-08-12T10:58:13Z DDEBUG Command: dnf repolist
2019-08-12T10:58:13Z DDEBUG Installroot: /
2019-08-12T10:58:13Z DDEBUG Releasever: 8
2019-08-12T10:58:13Z DEBUG cachedir: /var/cache/dnf
2019-08-12T10:58:13Z DDEBUG Base command: repolist
2019-08-12T10:58:13Z DDEBUG Extra commands: ['repolist']
2019-08-12T10:58:13Z DEBUG repo: downloading from remote: ol8_appstream
2019-08-12T10:58:16Z DEBUG Cannot download 'https://xxx': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried.
2019-08-12T10:58:16Z DEBUG repo: downloading from remote: ol8_baseos_latest
2019-08-12T10:58:18Z DEBUG Cannot download 'https://yyy': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried.
2019-08-12T10:58:18Z WARNING Failed to synchronize cache for repo 'ol8_appstream', ignoring this repo.
2019-08-12T10:58:18Z WARNING Failed to synchronize cache for repo 'ol8_baseos_latest', ignoring this repo.
2019-08-12T10:58:18Z DEBUG No module defaults found
2019-08-12T10:58:18Z DDEBUG timer: sack setup: 5157 ms
2019-08-12T10:58:18Z DEBUG Total packages: 0
2019-08-12T10:58:18Z DDEBUG Cleaning up.

The Solution

This issue can be caused due to any of the below:

  • Incorrect date and time settings
  • Old dnf cache available or expired
  • Proxy address not defined or incorrect proxy address provided in /etc/dnf/dnf.conf

Follow the steps outlined below to resolve the issue:

1. Check the date and time of this server and ensure its current.

or

2. Clear the expired or old cache using the below command:

3. Update correct proxy address in /etc/dnf/dnf.conf file, then its ability to install and list packages:

# cat /etc/dnf/dnf.conf
[main]
gpgcheck=1
installonly_limit=3
clean_requirements_on_remove=True
best=True
proxy=http://[proxy-host].[domain].com:[port]

4. Verify the repolist command to see if the issue is resolved now.

Also, try to install a package, for example ksh.

# dnf install ksh
Last metadata expiration check: 0:00:52 ago on Mon 12 Aug 2019 04:42:02 PM IST.
Dependencies resolved.
===================================================================================================
Package Arch Version Repository Size
===================================================================================================
Installing:
ksh x86_64 20120801-252.0.1.el8 ol8_appstream 928 k
Transaction Summary
===================================================================================================
Install 1 Package
Total download size: 928 k
Installed size: 3.5 M
Is this ok [y/N]: y
Downloading Packages:
ksh-20120801-252.0.1.el8.x86_64.rpm 129 kB/s | 928 kB 00:07
---------------------------------------------------------------------------------------------------
Total 129 kB/s | 928 kB 00:07
warning: /var/cache/dnf/xxx/packages/ksh-20120801-252.0.1.el8.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID ad986da3: NOKEY
Importing GPG key 0xAD986DA3:
Userid : ""
Fingerprint: 76FD 3DB1 3AB6 7410 B89D B10E 8256 2EA9 AD98 6DA3
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-geek
Is this ok [y/N]: y
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : ksh-20120801-252.0.1.el8.x86_64 1/1
Running scriptlet: ksh-20120801-252.0.1.el8.x86_64 1/1
Verifying : ksh-20120801-252.0.1.el8.x86_64 1/1
Installed:
ksh-20120801-252.0.1.el8.x86_64

Complete!

Понравилась статья? Поделить с друзьями:
  • Error failed to start network default
  • Error failed to setup chroot mnt
  • Error failed to set user interface authentication mode please modify the protocol first
  • Error failed to set phone to flashmode phoenix
  • Error failed to send host log message virtualbox