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

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


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

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

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

ONBOOT=no
NM_CONTROLLED=no
BOOTPROTO=dhcp
DNS1=8.8.8.8
DNS2=8.8.4.4

restart the network interface

ifdown eth0
ifup eth0

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.

proxy=http://xxx.xxx.xx.xx:8080

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

proxy_username=username
proxy_password=password

Tags:

Centos