Knowledge Base

Fix failed to synchronize cache for repo ‘AppStream’ or ‘BaseOS’, CentOS 8

Older builds if CentOS 8 encounters the error while installing or updating the repo, it shows error as “Failed to synchronize cache...

Written by admin · 1 min read >
CentOS logo

Older builds if CentOS 8 encounters the error while installing or updating the repo, it shows error as “Failed to synchronize cache for repo ‘AppStream’, ignoring this repo.” or “Failed to synchronize cache for repo ‘BaseOS’, ignoring this repo.” This type of error may be due to various underlying factors and a simple fix demonstrated here can resolve.

The main issue here largely occurs due to an expired or outdated DNF Cache. The other factors here might be due to incorrect Date and Time or Invalid or outdated CentOS BaseURL.

Let us explore each of the solutions separately, starting from the most common reason.

1. Fixing Expired or Outdated DNF Cache.

As of December 31, 2021, CentOS Linux 8 has officially reached its end of life. This signifies that the CentOS project will no longer provide support or pursue further development for CentOS 8. To ensure that we continue to receive updates beyond the specified EOL date, it is essential for us to transition our mirrors to vault.centos.org. By doing so, we will be able to receive any future updates that may become available. It is advisable to upgrade the CentOS to the latest RHEL based OS. You can check our guide to migrate or elevate your CentOS 8 to other RHEL-based AlmaLinux.
To change the repo mirror to vault.centos.org you need to run the following code.

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

Try running the update command now.

[root@nohost ~]# dnf update -y

This should resolve the correct repository and further update the system as required.

2. Clearing DNF Cache

Although the primary cause of this problem is generally an invalid repository or mirrorlist, it is important to consider that several other factors can contribute to its occurrence. To fix this, just run the following commands.

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

3. Fixing incorrect Date and Time.

In addition to the factors mentioned, an invalid date and time could also cause issues with AppStream or BaseOS mirrorlist synchronization. The off-sync time results in invalid requests/response between the servers. Fixing the server time to correct value can help ensure proper synchronization of the mirrorlist and prevent errors caused by mismatched timestamps. Use the following command to synchronize your time.

sudo date -s "$(wget -qSO- --max-redirect=0 google.com 2>&1 | grep Date: | cut -d' ' -f5-8)Z"

Maintaining the system integrity is crucial and fixing the issue of failing cache synchronization for appsteam or BaseOS will definitely help you to keep your system updated.

Remember to consider upgrading to a newer RHEL-based OS like AlmaLinux for continued support and development. For a detailed guide on migrating or elevating your CentOS 8 to AlmaLinux, refer to our comprehensive migration guide.

By following these steps, you can ensure that your CentOS 8 system remains updated and secure, even after its official end of life.

One Reply to “Fix failed to synchronize cache for repo ‘AppStream’ or ‘BaseOS’, CentOS 8”

Leave a Reply

Your email address will not be published. Required fields are marked *