How to Fix “Cannot find a valid baseurl for repo” in CentOS

One of the commonest errors CentOS users encounter when using YUM package manager (for example running yum update command), especially on a freshly installed system is the “Cannot find a valid baseurl for repo:…