Sanitarium by Zac Dreyer

CentOS: yum “Couldn’t resolve host ‘mirrorlist.centos.org'”

Posted by zac on Sunday, December 9th, 2012

I ran into an interesting issue with my fresh CentOS 6.3 install and yum. After configuring my eth0 I could ping any URL but when trying to run a yum update I get the following:

[root@hellrider ~]# yum 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 much a Googling I discovered that although most of the CentOS Official Forum posts indicate an issue with DNS no one seemed to touch on the actual issue which is that yum only reads the first nameserver entry in resolv.conf. What this means is that if you are using a local DNS server assigned via DHCP, like I do, or if you have something like Usermin installed which adds nameserver 127.0.0.1 as the first entry in resolv.conf you may end up getting this error.

So whats the solution? It’s actually fairly simple – insert nameserver 8.8.8.8, or what ever your preferred public open DNS server happens to be, as the first entry in /etc/resolv.conf. This would give yum a valid DNS server to resolve mirrorlist.centos.org with and should sort out your yum issues.

On a side note, if you have done a fresh minimal install of CentOS 6.3 I suggested brushing up on the vi commands. For a basic list of vi commands check out http://www.cs.colostate.edu/helpdocs/vi.html

Posted in: Featured, Linux.

Comments are closed.