Cannot find a valid baseurl for repo base 7 x86 64 centos 7 как исправить

Одной из самых распространенных ошибок, с которыми пользователи CentOS сталкиваются при использовании диспетчера пакетов YUM (например, при запуске команды обновления yum), особенно в недавно установленной системе, является «“Cannot find a valid baseurl for repo: base/7/x86_64”.».

В этой короткой статье мы покажем, как исправить ошибку “Cannot find a valid baseurl for repo в дистрибутиве CentOS Linux.

На следующем снимке экрана показана вышеупомянутая ошибка после выполнения команды yum для поиска пакета.

# yum search redis

Ошибка указывает на то, что YUM не может получить доступ к базовому репозиторию, который он использует для поиска информации о пакете.

В большинстве случаев возможны две причины ошибки: 1) проблемы с сетью и / или 2) базовый URL закомментирован в файле конфигурации репозитория.

Вы можете исправить эту ошибку следующими способами:

1. Убедитесь, что ваша система подключена к Интернету.

Вы можете попробовать пропинговать любое интернет-направление, например, google.com.

# ping google.com

Результат проверки связи указывает либо на проблему DNS, либо на отсутствие подключения к Интернету.

В этом случае попробуйте отредактировать файлы конфигурации сетевого интерфейса.

Чтобы определить сетевой интерфейс, выполните команду ip.

# ip add

Чтобы изменить конфигурацию интерфейса enp0s8, откройте файл /etc/sysconfig/network-scripts/ifcfg-enp0s8, как показано далее:

# vi /etc/sysconfig/network-scripts/ifcfg-enp0s8

Если это проблема DNS, попробуйте добавить серверы имен в файл конфигурации, как показано на рисунке.

DNS1=10.0.2.2 
DNS2=8.8.8.8

Затем перезапустите службу Network Manager с помощью команды systemctl.

# systemctl restart NetworkManager

Для получения дополнительной информации прочитайте нашу статью:

Как добавить сетевой шлюз или статический маршрут на CentOS / RHEL 6, 7

После внесения изменений в настройки сети попробуйте еще раз запустить пинг.

# ping google.com

Теперь выполните попытку еще раз запустить обновление yum или любую команду yum, которая показала вышеуказанную ошибку.

# yum search redis

2. Если система подключена к Интернету и DNS работает нормально, то должна быть проблема с файлом конфигурации репозитория /etc/yum.repos.d/CentOS-Base.repo.

Откройте файл, используя ваш любимый редактор командной строки.

# vi /etc/yum.repos.d/CentOS-Base.repo

Найдите раздел [base], попробуйте раскомментировать baseurl, удалив начальный символ # в строке baseurl, как показано на следующем снимке экрана.

Сохраните изменения и закройте файл.

Теперь попробуйте снова запустить команду yum.

# yum update

В этой статье мы объяснили, как исправить ошибку «Cannot find a valid baseurl for repo:» в CentOS 7.

Мы хотели бы услышать ваше мнение.

Вы также можете поделиться решениями, которые вы знаете, чтобы решить эту проблему, с помощью формы обратной связи ниже.

I am using Centos 7.1.1503 (core) as a VM. The host OS is Windows 10. I created this VM so this is a fresh installation of CentOS. My laptop has a direct connection to the internet, without a proxy.

When I execute the command yum update all I get with the error

Cannot find a valid baseurl for repo: base/7/x86_64

I went through various threads related to this error on Stackexchange.com and tried all the below suggestions:

  1. executed dhclient.

  2. Edited ifcfg-enp0s3 with information, as suggested in this question

  3. Uncommented the baseURL from the /etc/yum.repos.d/CentOS-Base.repo file

If I change the VirtualBox network settings to use «NAT», then I can see that yum is working without any issues. I can keep this setting, but I will not be able to access CentOS from my host OS, which is why I had used «Bridge» networking. When I use «Bridge» I am having this issue.

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

Cannot Find a Valid Baseurl for Repo Error

Cannot Find a Valid Baseurl for Repo Error

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

Ping a Host

Ping a Host

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

Identify Network Interfaces

Identify Network Interfaces

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

Ping a Host Again

Ping a Host Again

Now run try to run the yum update or the any yum command that was showing the above error, once more.

# yum search redis

Search for a Package

Search for a Package

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.

Edit Yum Repo File

Edit Yum Repo File

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.

If you read this far, tweet to the author to show them you care. Tweet a thanks

Photo of author

Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.


Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Hello I have download the minimal release of CENTOS 7 at this url
link download ISO centos 7.x

All work correctly…the PING and the network is OK. I ping to external HOST for example.

But when I digit :

[root@localhost ~]# yum update
Loaded plugins: fastestmirror


 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:

     1. Contact the upstream for the repository and get them to fix the problem.

     2. Reconfigure the baseurl/etc. for the repository, to point to a working
        upstream. This is most often useful if you are using a newer
        distribution release than is supported by the repository (and the
        packages for the previous distribution release still work).

     3. Disable the repository, so yum won't use it by default. Yum will then
        just ignore the repository until you permanently enable it again or use
        --enablerepo for temporary usage:

            yum-config-manager --disable <repoid>

     4. Configure the failing repository to be skipped, if it is unavailable.
        Note that yum will try to contact the repo. when it runs most commands,
        so will have to try and fail each time (and thus. yum will be be much
        slower). If it is a very temporary problem though, this is often a nice
        compromise:

            yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true

Cannot find a valid baseurl for repo: base/7/x86_64

Why?

This is another command:


root@localhost ~]# yum repolist all
Loaded plugins: fastestmirror
repo id                           repo name                           status
C7.0.1406-base/x86_64             CentOS-7.0.1406 - Base              disabled
C7.0.1406-centosplus/x86_64       CentOS-7.0.1406 - CentOSPlus        disabled
C7.0.1406-extras/x86_64           CentOS-7.0.1406 - Extras            disabled
C7.0.1406-fasttrack/x86_64        CentOS-7.0.1406 - CentOSPlus        disabled
C7.0.1406-updates/x86_64          CentOS-7.0.1406 - Updates           disabled
base/7/x86_64                     CentOS-7 - Base                     enabled: 0
base-debuginfo/x86_64             CentOS-7 - Debuginfo                disabled
base-source/7                     CentOS-7 - Base Sources             disabled
centosplus/7/x86_64               CentOS-7 - Plus                     disabled
centosplus-source/7               CentOS-7 - Plus Sources             disabled
cr/7/x86_64                       CentOS-7 - cr                       disabled
extras/7/x86_64                   CentOS-7 - Extras                   enabled: 0
extras-source/7                   CentOS-7 - Extras Sources           disabled
fasttrack/7/x86_64                CentOS-7 - fasttrack                disabled
updates/7/x86_64                  CentOS-7 - Updates                  enabled: 0
updates-source/7                  CentOS-7 - Updates Sources          disabled
repolist: 0
[root@localhost ~]#

The content of the file /etc/yum.repos.d/CentOS-Base.repo

[root@localhost ~]# cat /etc/yum.repos.d/CentOS-Base.repo
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#

[base]
name=CentOS-$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#released updates
[updates]
name=CentOS-$releasever - Updates
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

[root@localhost ~]#

asked Sep 11, 2015 at 13:27

Daniele Grillo's user avatar

Daniele GrilloDaniele Grillo

9814 gold badges12 silver badges31 bronze badges

3

The problem is config of dhcp, try typing

dhclient

Robert's user avatar

Robert

5,27843 gold badges65 silver badges115 bronze badges

answered Jan 7, 2016 at 11:25

José Pérez Aniorte's user avatar

1

Check your resolv.conf to see where your name server is pointing. Make sure it’s something legit as mine was pointing to an old DNS server on the network that was wiped out. I updated it with the new IP address et voila!

answered Jan 22, 2016 at 23:47

user297149's user avatar

user297149user297149

761 silver badge1 bronze badge

1

Uncomment baseurl in this file: /etc/yum.repos.d/CentOS-Base.repo

#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/

In this block:

[base]
name=CentOS-$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

By uncomment, I mean change this: #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/, to this: baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/ (remove the #).

answered Sep 11, 2015 at 13:48

ryanpcmcquen's user avatar

ryanpcmcquenryanpcmcquen

6,2053 gold badges23 silver badges35 bronze badges

5

sudo sed -i 's/https/http/g' /etc/yum.repos.d/epel.repo

answered Jun 1, 2018 at 16:07

Serdar Karaca's user avatar

1

First of all, I was able to fix this issue as mentioned above by using «dhclient». But you will have to run this command every time you reboot.
This could be because your Ethernet is disabled and you have to enable it explicitly. Click here to see the reason. For a permanent fix I edited /etc/sysconfig/network-scripts/ifcfg-{YOURETHERNET} (In my case it was /etc/sysconfig/network-scripts/ifcfg-eth0) and changed ONBOOT=yes and boom!!!

answered Jun 24, 2016 at 0:27

Purushothaman's user avatar

It is the error coming from the https connection in /etc/yum.repos.d/epel.repo after you installed ius-release.rpm through

sudo yum install -y https://centos7.iuscommunity.org/ius-release.rpm

You need to do following stuff in /etc/yum.repos.d/epel.repo.

baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch
#mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch

Uncomment baseurl and comment line beginning with mirrorlist=.

user247702's user avatar

user247702

23.5k15 gold badges110 silver badges157 bronze badges

answered Dec 14, 2016 at 12:48

tonydeck's user avatar

1

I landed here because I had added a bad mirror for a different dependency (passenger, for a Rails app), and solved this problem by just deleting the bad mirror:

rm /etc/yum.repos.d/YOUR-BAD-DEPENDENCY-NAME.repo

e.g.

rm /etc/yum.repos.d/passenger.repo

answered May 30, 2017 at 20:53

duhaime's user avatar

duhaimeduhaime

25.1k16 gold badges165 silver badges221 bronze badges

This issue can also happen if the yum repository in question is actually offline or not responding correctly.

This can be a little tricky to diagnose, but the yum repo might respond to ping and respond to web requests on the base URL, but does not serve up packages correctly.

To find the problematic repo, I’ve found what works best is to move each repo file out of /etc/yum.repos.d and into a temporary holding folder (e.g., /root/yum_bak) and run yum update after removing each repo. Once you’ve moved the problematic repo out of /etc/yum.repos.d then yum update (and other yum commands will start working normally again. Move the working yum repos back into /etc/yum.repos.d and you’re back in business.

Just don’t forget to move the problematic repo back into /etc/yum.repos.d after the outage has ended.

answered May 11, 2018 at 19:58

Elliot B.'s user avatar

Elliot B.Elliot B.

16.8k10 gold badges80 silver badges101 bronze badges

1

I had this problem in a company environment with MITM proxy after adding the EPEL repo with

yum install epel-release

This doesn’t happen before (e.g. on yum update). I checked all answers and none of them fixed my problem.
Figured out that the other repos use http by default, where epel use https:

# grep mirror /etc/yum.repos.d/epel.repo
metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch&infra=$infra&content=$contentdir
metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-7&arch=$basearch&infra=$infra&content=$contentdir
metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-source-7&arch=$basearch&infra=$infra&content=$contentdir

So I copied our company root CA in the CentOS trust store and update it:

cp /home/user/my-ca.crt /etc/pki/ca-trust/source/anchors/
update-ca-trust

After adding the cert, updating and installing packages from the EPEL repo works fine!

answered Mar 21, 2020 at 18:47

Lion's user avatar

LionLion

16.1k23 gold badges84 silver badges145 bronze badges

Skip to content

FEATURE-IMAGE-BASE-URL-1

I had to write this from personal experience based on the issues I had with my machine, so if you have centos7 installed on VMWare Workstation Pro, I know that at some point in time you will experience this or it has probably happened already. In this article, I will walk you through the fastest and most effective step to get your machine up and running with just two simple commands. Please check other guides and materials: setting-up-SELinux-on-a-linux-server/ and how-to-create-and-deliver-a-report-on-system-utilization-on-a-linux-based-os/, and how-to-create-a-static-pod-in-kubernetes-with-demos-that-can-help-you-become-a-better-kubernetes-administrator/ and how-to-use-container-insights-to-get-the-full-benefits-of-azure-monitor-for-azure-kubernetes-workload/

base1

cannot find a valid baseurl for repo

So, for the first step, we have to make sure that we are logged in as root and then execute the command below

#ONBOOT=no

on-boot-1

On boot

The final command is straight forward just type the command dhclient. The Internet Systems Consortium DHCP Client, dhclient, provides a means for configuring one or more network interfaces using the Dynamic Host Configuration

#dhclient

DHclient

dhclient

The next step would be to do a yum update, if it runs, and shows that it’s downloading packages then the problem has been fixed. compare the image below with the first one in this guide

yumupdate

yum update

The firmware was replaced as shown below

completed

process completed

What I like about the Linux shell is that if you are attentive enough, it will either show you the next steps or will tell you when a process has been completed as shown above.

Summary

We used 2 commands to solve a well-known problem that centos7 always has especially if you are running it on VMWare workstation pro. The commands are ONBOOT=no and dhclient.

Понравилась статья? Поделить с друзьями:
  • Как правильно составить меню на свадьбу 40 человек
  • Как составить каноническое уравнение медианы
  • Как найти удельную теплоемкость газа при
  • Как найти вики шоу ютуб
  • Как составить график дежурств на год в виде таблицы