Sanitarium by Zac Dreyer

CentOS: yum “Couldn’t resolve host ‘'”

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 error was
14: PYCURL ERROR 6 - "Couldn't resolve host ''"
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 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, 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 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

Posted in: Featured, Linux.

Comments are closed.