How to fix CentOS Yum Error – “4 is not a valid release”

After CentOS 4 hit End of Life in February (No updates after 29 February 2012), you may have noticed the following error coming from the “yum” installer:
not using ftp, http[s], or file for repos, skipping – 4 is not a valid release or hasn’t been released yet

However, there is very easy way to get “yum” working again without upgrading everything to newer version of CentOS.

  1. Login to your server/SSH using root
  2. Open /etc/yum.repos.d/CentOS-Base.repo in an editor (vi/vim)
  3. Comment out the “mirrorlist” entries
  4. Uncomment the “baseurl” entries and change them to$basearch

That’s it!