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

DNS and BindAfter 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 nameserver nameserver

See how VirtualMin adds the 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 entry at the botton of the /etc/resolv.conf file, like so:

nameserver nameserver nameserver

After that, eveything worked great.

IMPORTANT: The above examples of the /etc/resolv.conf file use the IP Addresses of the Google Public DNS.



Thank you! I did a minimal Centos 6.3 install that left the resolv.conf file blank and I was scratching my head over this one. Cheers!


Indeed that was the problem. Such a stupid error.


thanks a lot, perfecto!!


THANKS!!!!! After looking and looking...


how can i sovle following problem i am working with CentOs [root@sagar ~]# yum install upgrade Loaded plugins: fastestmirror, refresh-packagekit, security Loading mirror speeds from cached hostfile Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=6&arch=i386&repo=os error was 14: PYCURL ERROR 6 - "Couldn't resolve host 'mirrorlist.centos.org'" Error: Cannot find a valid baseurl for repo: base

Chris Blackwell

I don't think moving to the end of resolv.conf is really the best solution, this would mean that all dns queries have to be made externally which is very ineffiecient. The likely cause of your problem was that the local dns server (bind if you're using virtualmin) isn't allowing recursive lookups, which it should do from localnets but not remote you should check /etc/named.conf, mine contains options { /* just showing relevant portions */ allow-query { any; }; recursion yes; allow-recursion { localnets;; }; } now you can keep at the top of resolv.conf by allowing bind to do recursive dns lookups for queries but only from the local machine.


@ sagar I would checkto see if you had a network connection at all before trying to diagnose it. @ Chris I concede that moving isn't always the best solution, but it will work jut fine for the majority of situations. Thank you for the alternate solution!

Ronan Loftus

Thank you. This worked perfectly for me on fedora 17 and now it seems all errors are gone, greatly appreciated!

Me Too

I also had this problem with a fresh install of CentOS 6.3 Not too happy - had to work out the problem and the text left in resolv.conf was not too helpful. # Generated by NetworkManager # No nameservers found; try putting DNS servers into your # ifcfg files in /etc/sysconfig/network-scripts like so: # #DNS1=XXX.XXX.XXX.XXX #DNS2=XXX.XXX.XXX.XXX #DOMAIN=localhost.localdomain


I had the same problem, however, my resolve.conf had been automatically generated and included a search and a domain line before the nameserver lines. Moving these to the bottom of the file sorted things.


Thank you very much.


Thanks...this is certainly one of Centos' dumbest features :-P


Thanks... It worked. After some google searching, you had the solution.


i am trying to run command yum install glibc.i686 i have added above lines in resolv.conf than i get error "The requested URL returned error: 403" pls give some solution


I always disable "NetworkManager" on a server.


this one really help me a lot. thanks




What worked for me is just using the Google public nameserver in your example, the as the first line in resolv.conf This came AFTER I unsuccessfully tried my own router's nameserver at and my local ISP's nameserver and one of my own server's nameserver ... which is very strange to me that only Google's public nameserver works for me. Of course, the other nameservers work with all other devices of my office and my home ... except CentOS 6.3 and 6.4 which I just installed this week. The other nameservers *do* work with my old CentOS 5.8 server for some reason and another CentOS server installation many months ago. I have experimented a bit, and the only thing which works well for me is Google's nameserver as the first line. As I have spent hours on this problem, with multiple reinstalls of CentOS 6.3 and 6.4, both minimal and full DVD installation of "Web server", with the same failure experiences on this one DNS point, I am very appreciative of your help and wish to potentially save many others hours as well. For example, with my own LAN nameserver, I can ping ibiblio.org but if I immediately thereafter try to ftp ibiblio.org then ftp fails (" No address associated with hostname"), but I can ping again successfully. It's actually your mention of the Google public nameservers which were the solution which worked for me. It still leaves the issue of "WHY?" unanswered. Since many people have reported having the same problem, surely countless other people are having it as well. It wasn't fixed between CentOS 6.3 and CentOS 6.4 . Nor was it fixed by a yum update , as I just put mirror.centos.org into my hosts file with the IP I got from ping so I did get a yum update, but the yum update still didn't fix the problem. To reiterate, ping works OK with various resolv.conf settings but yum and ftp did not work on hostname lookups with the same settings. It's only on my latest 6.4 installation that I tried I put Google's public nameserver as the *first* line of resolv.conf , which worked. However, if Google's public nameserver was the second line then it failed. Regarding another user's solution by working on named, I do not have named installed and I suspects others do not, either. Installing named and properly configuring it is apparently unnecessary to solve this problem. Just try different nameservers until you find one which works for your CentOS, or use Google's.


Hi Works, the problem, as mentioned in the post, is that some programs only check the first resolver that's listed, and not the others that are listed. Once you made the first entry, that was the entry that the programs that only check the first entry used. Other programs, like ping, check all resolvers until a resolution is made, and hence you can ping things just fine but they still don't resolve with programs that only check the first entry. Hope this helps!

buzz blustein

Brilliant solution Thanks, hope I can do something for you in the future


You Rock!!! You are genius!! Love you man....


I've the same problem and i looked into resolv.conf file.. the name server with 127.**.**.** is at the bottom in that file. but the issue is not resolved yet..


I had the same problem after a fresh install, I too checked resolv.conf and saw that it was empty. I also ran ifconfig and saw that I had no IP address so I checked /etc/sysconfig/network-scripts/ifcfg-eth0 and saw that ONBOOT=no once I changed it to yes I reboot and the problem was solved.


Helped me thank u


Good, my system didn't reboot for quite a long time, but today after reboot the yum stop work. Your blog do helps a lot, problem is DNS configure clean up!


Thanks, you saved me a lot of troubleshooting, in a real short time!


Thank you,, it worked..


thanksss, I was with these problem , up installation in this moment in my pc


Thanks!! It saved me :)


OMG, cannot believe it, THANK YOU so much, after many days it's finally working! >:) I hate linux :))


Josh you're the man!!! Spot on helped me a lot


tnx worked perfect .


I also faced the same error on my system (OpenNode 6 based on Centos 6). I added the following at the last line in "/etc/sysconfig/network-scripts/ifcfg-vmbr0" (because i'm in bridged mode) , but for normal setups it will probably be "/etc/sysconfig/network-scripts/ifcfg-em1" ######## DNS1="xxx.xxx.xxx.xxx" DNS2="xxx.xxx.xxx.xxx" DNS3="" ######## Hope it helps someone :)

a name

Could not resolve 'vault.centos.org'! I've had this problem for years, god lord it was this easy to solve it LOL.


Great. Working like a charm Thx

Bryan Mora Ramos

Muchas gracias, de verdad que me sacaste de un aprieto, un novato como yo queriendo aprender de este mundo, de nuevo gracias.


good...very good...thank you so much!


Thanks, i had the network manager generated resolv.conf file and it did not have the reference. Once added (to the top of file), things work fine. I just got to know that that the IP address( corresponds to the host google-public-dns-a.google.com. Thanks for the tip.

Aravinthan K

Thanks Man :-) Really Help!!

Write your comment

(it will not be displayed)

Leave this field empty: