One of the commonest errors CentOS users encounter when using YUM package manager (for example running yum update command), especially on a freshly installed system is the “Cannot find a valid baseurl for repo: base/7/x86_64”.
In this short article, we will show how to fix “cannot find a valid baseurl for repo” error in CentOS Linux distribution.
The following screenshot shows the above error after running a yum command to search for a package.
# yum search redis
The error indicates that YUM is not capable of accessing the base repository that it uses to find package information. In most cases, there are two possible causes of the error: 1) network issues and/or 2) base URL being commented out in the repository configuration file.
You can fix this error in the following ways:
1. Make sure that your system is connected to the Internet. You can try to ping any internet direction, for example, google.com.
# ping google.com
The ping result indicates either a DNS problem or no Internet connectivity. In this case, try to edit network interface configuration files. To identify your network interface, run the ip command.
# ip add
To edit the configuration for interface enp0s8, open the file /etc/sysconfig/network-scripts/ifcfg-enp0s8 as shown.
# vi /etc/sysconfig/network-scripts/ifcfg-enp0s8
If it is a DNS problem, try to add the Nameservers in the configuration file as shown.
DNS1=10.0.2.2 DNS2=8.8.8.8
Then restart the Network Manager service with the systemctl command.
# systemctl restart NetworkManager
For more information, read our article: How to Configure Network Static IP Address and Manage Services on RHEL/CentOS 7.0.
After making changes in the network settings, try to run a ping once more.
# ping google.com
Now run try to run the yum update or the any yum command that was showing the above error, once more.
# yum search redis
2. If the system is connected to the Internet and DNS is working fine, then there should be an issue with the repo configuration file /etc/yum.repos.d/CentOS-Base.repo.
Open the file using your favorite command-line editor.
# vi /etc/yum.repos.d/CentOS-Base.repo
Look for the [base]
section, try uncommenting the baseurl
by removing the leading #
on the baseurl line as shown in the following screenshot.
Save the changes and close the file. Now try to run yum command again.
# yum update
In this article, we have explained how to fix the “Cannot find a valid baseurl for repo:” error in CentOS 7. We would like to hear from you, share your experience with us. You can also share solutions you know to fix this issue, via the feedback form below.
This solution did not solve my issue of “Cannot find a valid baseurl for repo:” error in CentOS” any other suggestion.
That helped me. Thank you…