How can I fix "cannot find a valid baseurl for repo" errors on CentOS?

I finished installing CentOS 6, but when I tried running yum update I got:

[root@centos6test ~]# yum update
Loaded plugins: fastestmirror, refresh-packagekit
Determining fastest mirrors
Could not retrieve mirrorlist
error was 14: PYCURL ERROR 6 - "" Error: Cannot find a valid baseurl for repo: base

Why is that happening? How can I fix it?

Asked By: shivshankar


First you need to get connected, AFAIK CentOS 6 minimal set your network device to ONBOOT=No, just do a dhclient with admin privileges to your network interface and you should be up and running:

$ sudo dhclient

Answered By: Jorge

If pinging a well known host by its name (e.g. ping returns ping: unknown host but pinging an ip (e.g. ping works fine then you have a DNS resolution issue — try adding these entries to /etc/resolv.conf:


I had the same problem yesterday and I spent hours trying to solve it. The solution ended up being simple.

Delete the contents of /etc/yum.repos.d/remi.repo and then execute

# yum update

It’s done! The file’s content will start the download again and be configured.

Answered By: victorkurauchi

I edited the file /etc/yum.repos.d/CentOS-Base.repo and uncommented baseurl:

name=CentOS-$releasever - Base
Answered By: Mastergalen

I had the same issue and it got resolved after I edited /etc/yum.conf file. If you are running on proxy server and the IP which is given to the server is bypassed but still when you open in browser (IE – we need to give check mark on proxy but no need to give username and password.)

Add this following line in the main section of the file /etc/yum.conf file.


ie, substituting the proxy address with actual proxy. Also change the port number if it is not 8080.

If proxy requires authentication, add this also to the file

Answered By: Anand TS

Here’s yet another possibility that I stumbled upon, causing this problem:

I was using a Puppet module to create the EPEL repo for CentOS, the stahnma/epel module.

Within the module it constructed the repo URL with the variable ::os_maj_version which didn’t exist in my list of facts. I had to replace that with ::operatingsystemmajrelease.

So the URL in /etc/yum.repos.d/epel.repo was malformed.

Answered By: Mojo

I had been struggling with the same problem on Centos6.4 x86_64. I got the following error

Could not retrieve mirrorlist error was 14: PYCURL ERROR 6 - "Couldn't resolve host ''" Error: Cannot find a valid baseurl for repo: base

So, I fixed it by these steps:

edit network interface. For my case, I used eth0 in CentOS 6.X
In CentOS 7 you can use the "ensxxx" interface.

vim /etc/sysconfig/network-scripts/ifcfg-eth0

update NM_CONTROLLED to no


restart the network interface

ifdown eth0
ifup eth0
Answered By: Raja David

All previous answers are correct but unfortunately did not work for me.
The below command worked for me:

Warning this will delete all of you Centos repos !!!
use this at your own risk

mkdir ~/backup
cp -r /etc/yum.repos.d/Cen* ~/backup
rm /etc/yum.repos.d/Cen*
Answered By: grepit

It happened to me on a Centos 7 environment, and I was able to solve it with the following command:

yum clean all

I had not run any yum command for a few months, seems like the cached metadata got obsolete.

Answered By: Elouan Keryell-Even

Happened to me on CentOS 6 as it has reached end-of-life due to which no mirrors work now. Though you can use Vault repo where everything has been moved.

For CentOS 6, do:

curl --output /etc/yum.repos.d/CentOS-Base.repo

or take a look here.
This should fix up yum.

Answered By: subtleseeker

My user’s problem was simpler. He needed an extra repo added, so I copied my entry to him in a chat window. He added it to the repo file and got the error in the subject. After some playing around I deleted the new entry, copied and pasted an existing entry from within his own file and then edited the changes to reflect the added repo. It worked fine.

So the problem was some sort of formatting error caused by the way he copied and pasted the content into the file.

Answered By: Sinc

I had a slightly different error on our CentOS 7. I followed one of the suggestions and fixed it.

The error is:

$ sudo yum update mesa-libgbm


Could not retrieve mirrorlist error was
14: curl#6 - "Could not resolve host:; Name or service not known"

 One of the configured repositories failed (Unknown),
 and yum doesn't have enough cached data to continue. At this point the only
 safe thing yum can do is fail. There are a few ways to work "fix" this:


     3. Run the command with the repository temporarily disabled
            yum --disablerepo=<repoid> ...


Cannot find a valid baseurl for repo: ius/x86_64

I tried again using the 3rd suggestion and it worked.

Answered By: M. Fayer
Categories: Answers Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.