Operations 5 min read

How to Fix Yum 404 Errors Caused by Missing $releasever Variable on CentOS

This article explains why yum install commands return 404 errors on CentOS due to an undefined $releasever variable, analyzes the root cause in yum configuration, and provides a step‑by‑step solution and useful troubleshooting tips for operations engineers.

360 Zhihui Cloud Developer
360 Zhihui Cloud Developer
360 Zhihui Cloud Developer
How to Fix Yum 404 Errors Caused by Missing $releasever Variable on CentOS

Problem Phenomenon

When running yum install on a CentOS system, every package installation returns a 404 error, initially suggesting a broken repository.

Error Output

Loaded plugins: fastestmirror, security
http://***.***.360.cn:/addops/$releasever/os/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404 Not Found"
Trying other mirror.
Error: Cannot retrieve repository metadata (repomd.xml) for repository: ADDOPS-base. Please verify its path and try again

Analysis

The URL contains the variable $releasever (displayed as %24releasever ) which is not expanded, leading to the 404. The variable is defined by the distroverpkg setting in /etc/yum.conf , which points to the centos-release package.

On the affected machine the centos-release package is missing, so $releasever cannot be resolved.

yum.conf snippet
yum.conf snippet

Solution

Temporarily replace $releasever with the actual version number (e.g., 6 ) in the repository configuration, install the centos-release package, then restore the original variable.

Useful Tips

/usr/bin/python -c 'import yum, pprint; yb = yum.YumBase(); pprint.pprint(yb.conf.yumvar, width=1)'

This Python one‑liner prints the current yum variables, showing releasever: '6' .

yum whatprovides centos-release

Shows which package provides centos-release and its repository information.

Conclusion

Mastering yum and understanding its variables is a fundamental skill for any operations engineer.

operationsTroubleshootingPackage ManagementCentOSyumreleasever
360 Zhihui Cloud Developer
Written by

360 Zhihui Cloud Developer

360 Zhihui Cloud is an enterprise open service platform that aims to "aggregate data value and empower an intelligent future," leveraging 360's extensive product and technology resources to deliver platform services to customers.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.