Linux – CentOS 5.7 – Cannot retrieve repository metadata

centoslinuxrepositoryupdateyum

I got this strange error today and I'm not able to fix it:

root@server# yum -y update
Loaded plugins: allowdowngrade
YumRepo Error: All mirror URLs are not using ftp, http[s] or file.
 Eg. </html>/
removing mirrorlist with no valid mirrors: /var/cache/yum/addons/mirrorlist.txt
Error: Cannot retrieve repository metadata (repomd.xml) for repository: addons. Please verify its 
path and try again
root@server#

with disabled repo "addons":

root@server# yum update --disablerepo=addons
Loaded plugins: allowdowngrade
YumRepo Error: All mirror URLs are not using ftp, http[s] or file.
 Eg. </html>/
removing mirrorlist with no valid mirrors: /var/cache/yum/base/mirrorlist.txt
Error: Cannot retrieve repository metadata (repomd.xml) for repository: base. Please verify its path and try again
root@server#

with "yum clean all":

root@server# yum clean all
Loaded plugins: allowdowngrade
Cleaning up Everything
root@server# yum -y update
Loaded plugins: allowdowngrade
YumRepo Error: All mirror URLs are not using ftp, http[s] or file.
 Eg. </html>/
removing mirrorlist with no valid mirrors: /var/cache/yum/addons/mirrorlist.txt
Error: Cannot retrieve repository metadata (repomd.xml) for repository: addons. Please verify its path and try again
root@server#

edit 22-09-2011: rpm –verify centos-release yum

root@server# rpm --verify centos-release yum
..5....T  c /etc/issue
..5....T  c /etc/issue.net
S.5....T  c /etc/yum.repos.d/CentOS-Base.repo
missing   c /etc/yum.repos.d/CentOS-Debuginfo.repo
S.5....T  c /etc/yum.repos.d/CentOS-Vault.repo
package yum is not installed
root@server#

How can I fix this issue ?

Best Answer

The "Cannot retrieve repository metadata" error looks like a red-herring. The real error seems to be this:

YumRepo Error: All mirror URLs are not using ftp, http[s] or file.
 Eg. </html>/

Are your Yum repo files corrupt?

The files at /etc/yum.conf and /etc/yum.repos.d/*.repo are provided by the yum and the centos-release packages (Test this with rpm -q --whatprovides /etc/yum.conf /etc/yum.repos.d/*).

Try verifying the files in /etc/yum.repos.d/ against the RPM files. Have there been any changes?

In the following example, the file CentOS-Base.repo has been locally modified:

% rpm --verify centos-release yum
S.5....T  c /etc/yum.repos.d/CentOS-Base.repo

If you discover that these files have indeed been changed, then you could try reinstalling the rpms, or extracting just the few files that you need and manually move them into place. Back up your old files first, for investigation later.