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:

    [[email protected] ~]# yum update
    Loaded plugins: fastestmirror, refresh-packagekit
    Determining fastest mirrors
    Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=6&arch=i386&repo=os
    error was 14: PYCURL ERROR 6 - "" Error: Cannot find a valid baseurl for repo: base
    

    Why is that happening? How can I fix it?

    Are you connected to the network? Can you ping mirrorlist.centos.org?

    What happens if you run `curl 'http://mirrorlist.centos.org/?release=6&;arch=i386&repo=os'` ?

  • Jorge

    Jorge Correct answer

    9 years ago

    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 used to setup dhcp client on my remote server using ssh according to this answer and now I lost the connection because server IP is dynamically changed now and I was not thinking of that case before applying changes. This answer is fallacious without enough description and leads to misunderstandings.

    For CentOS-7 (1611) version, the `ONBOOT=No` is located in a file like `/etc/sysconfig/network-scripts/ifcfg-enp0s3`. I edited that file to `ONBOOT=yes` and reboot can fix it.

    Changing to `ONBOOT=yes` in `/etc/sysconfig/network-scripts/ifcfg-enp0s3` works for me, thanks @JohnnyWong

License under CC-BY-SA with attribution


Content dated before 6/26/2020 9:53 AM