This usually happens when the server can’t connect to the Internet because of can’t resolve to name server.
Solution
Take a look at /etc/resolv.conf file. I had following Keep “search localdomain” at the bottom, so something like below Save the file and try to perform yum. It was all good for me. Note: nameserver may differ as shown in the example above. The point here is to keep localhost at the bottom and things should move. Interested in learning about Linux administration?