Error: Failed to synchronize cache for repo 'updates'

73.7k Views Asked by At

I am using Fedora 25. I'm trying to install gcc on fedora25 using the sudo dnf install gcc command. It is always showing:

Error: Failed to synchronize cache for repo 'updates'

I am also getting the same error when I try to install other packages. What am I doing wrong?

9

There are 9 best solutions below

1
Rema On

I had a similar problem (with the same error message appearing) when I was trying to do the update while I was traveling to another country. After I was back, it was automatically resolved and I was able to update and do everything as normal again.

You may try to use the answer in the comments on this other question, which suggests using

 yum-deprecated update

Otherwise, this error probably means you need to change your local links to the mirrors, by

dnf --refresh upgrade 

as answered here or manually to a one that works where you are now using something like the instructions in this url: https://www.cyberciti.biz/tips/rhel5-fedora-core-add-new-yum-repository.html

0
jcope On

I just ran into this as well. Adding the verbose flag showed the $releasever wasn't set in the url. Check this yourself with dnf update -v

Look for these lines in the output:

Cannot download 'https://mirrors.fedoraproject.org/metalink?repo=fedora-$releasever&arch=x86_64': Cannot prepare internal mirrorlist: file "repomd.xml" was not found in metalink. 
Error: Failed to synchronize cache for repo 'fedora'

I fixed the issue with dnf clean all && dnf update --releasever=25. This overrides the $releasever with the one you supply. After that, I was able to update and install rpms again.

2
silly On

try clean and update before install solved my problem:

dnf clean all

dnf update

dnf install gcc

0
ysnrgt On

In my case, the proxy server respond content-length:0 for CONNECT method + https. The libcurl of feodra26 closed the connection for content-length:0.

Http instead of https worked. But the package was legacy and moved to archive. The archive is only available for the https site.
UH Mathematics site provided mirror fadora26. I resolved it by using the site with http.

http://pubmirror2.math.uh.edu/fedora-buffet/archive/

0
hyorman On

I tried this and solved my problem.

$sudo dnf repolist

0
Akhilesh Kulkarni On

I am Using Fedora 30. After upgrading fedora 29 to 30 I have faced same issue as "failed to synchronize cache for repo updates". I have tried the following and it resolved my problem.

sudo dnf distro-sync

sudo dnf autoremove
0
Andrey Semakin On

This issue happened for me because of some internet censorship/restrictions in my region (Russia). Tried to use -v flag (long hashes are shortened):

error: Downloading successful, but checksum doesn't match.
Calculated: 1968~51f5(sha512) 1968~51f5(sha512)
Expected: 0d18~d874(sha512) 512d~f41e(sha512)
(http://mirror.linux-ia64.org/fedora/linux/updates/30/Modular/x86_64/repodata/repomd.xml).

Then I enabled VPN and retried dnf update command and now everything looks OK.

UPD: people say that this may be caused by fastestmirror=True setting in /etc/dnf/dnf.conf. I don't think that it is my case because here is no such setting in my config file and fastestmirror is set to False by default.

3
Thorsten Scherler On

Same happened to me doing the upgrade from 29 to 30. I fixed with following https://fedoramagazine.org/upgrading-fedora-29-to-fedora-30/ and then

dnf distro-sync --allowerasing  --releasever=30

0
Danila Vershinin On

In /etc/dnf/dnf.conf make sure:

zchunk=false

This fixes it with some mirrors, especially Yandex one.