yum "Couldn't resolve host 'mirrorlist.centos.org'" for CentOS 6
I ran into an issue recently where I could ping URL's just fine, but when I ran the "yum update" command yum could not resolve anything. I would get error messages like the following:
[root@viviotech ~]# yum -y update Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=6&arch=x86_64&repo=os error was 14: PYCURL ERROR 6 - "Couldn't resolve host 'mirrorlist.centos.org'" Error: Cannot find a valid baseurl for repo: base
After a bit of digging, and absolutely no help from my friend Google, I asked one of the Vivio technicians about it and he said he'd seen it on other servers - specifically servers with VirtualMin.
Take a look at the resolve.conf file:
nameserver 127.0.0.1 nameserver 8.8.8.8 nameserver 8.8.4.4
See how VirtualMin adds the 127.0.0.1 address first? Apparently YUM will ONLY check the very first entry in the /etc/resolve.conf file when it looks for the server to resolve IP Addresses. In this case, the local DNS resolver was not configured to use forwarders, so the YUM process would ask the local DNS server where to find "mirrorlist.centos.org", and when the local resolver didn't know, YUM would simply report an error instead of looking at the other resolvers in the /etc/resolve.conf list. This is why I could ping URL's just fine, but YUM could not find them.
The solution to this was to simply place the 127.0.0.1 entry at the botton of the /etc/resolv.conf file, like so:
nameserver 8.8.8.8 nameserver 8.8.4.4 nameserver 127.0.0.1
After that, eveything worked great.
IMPORTANT: The above examples of the /etc/resolv.conf file use the IP Addresses of the Google Public DNS.
CHECK THIS ALSO
I have been using several VMs for simulating a multi-node environment. Most of my VMs are CentOS.
After installing CentOS 6.4 I got the following error when I tried “yum update“:
After installing CentOS 6.4 I got the following error when I tried “yum update“:
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=6&arch=x86_64&repo=os error was 14: PYCURL ERROR 6 - "Couldn't resolve host 'mirrorlist.centos.org'" Error: Cannot find a valid baseurl for repo: base
To fix this error I updated NM_CONTROLLED to “no” in the file /etc/sysconfig/network-scripts/ifcfg-eth0
After this I restarted the network interface using the following commands:
ifdown eth0
ifup eth0
After doing the above the yum update started working.
No comments:
Post a Comment