Ошибка cannot find a valid baseurl for repo base

30 ноября 2020 года поддержка операционной системы CentOS 6 была прекращена. Кроме отсутствия новых обновлений это событие привело к невозможности использования утилиты yum для работы со списком пакетов.
При попытке выполнения действий yum update, yum install, yum search и т.п. система начала выдавать ошибку:

~]# yum update
Loaded plugins: fastestmirror
Setting up Update Process
Loading mirror speeds from cached hostfile
YumRepo Error: All mirror URLs are not using ftp, http[s] or file.
Eg. Invalid release/repo/arch combination/
removing mirrorlist with no valid mirrors: /var/cache/yum/x86_64/6/base/mirrorlist.txt
Error: Cannot find a valid baseurl for repo: base

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

Решение для исправления работы Yum в CentOS 6

Для начала давайте выполним команду:

yum clean all

Это позволит сбросить все кэши и в дальнейшем избавит от возможных проблем.

Теперь откроем файл /etc/yum.repos.d/CentOS-Base.repo и закомментируем строки «mirrorlist=…» и «baseurl=…»

Т.е. перед ними поставим символ «#» и в результате получим:

#mirrorlist=...
#baseurl=...

Ниже этих двух строк добавляем в каждую секцию baseurl, в котором в качестве хоста указываем https://vault.centos.org, остальные параметры из старого baseurl и сохраняем результат, например:

baseurl=https://vault.centos.org/centos/$releasever/os/$basearch/

В результате для каждой секции файла у нас будет 5 разных вариаций:

baseurl=https://vault.centos.org/centos/$releasever/os/$basearch/
baseurl=https://vault.centos.org/centos/$releasever/updates/$basearch/
baseurl=https://vault.centos.org/centos/$releasever/extras/$basearch/
baseurl=https://vault.centos.org/centos/$releasever/centosplus/$basearch/
baseurl=https://vault.centos.org/centos/$releasever/contrib/$basearch/

Полный файл /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/
baseurl=https://vault.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

#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/
baseurl=https://vault.centos.org/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

#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/
baseurl=https://vault.centos.org/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

#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/
baseurl=https://vault.centos.org/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/contrib/$basearch/
baseurl=https://vault.centos.org/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

Вот и все! Теперь Вы сможете ввести любую команду yum (yum install, yum update, yum search…) и насладится прежней работой.
При этом помните, что обновления для CentOS 6 с 30 ноября 2020 года больше не выпускаются, а хостинг VPS/VDS или Dedicated сервер лучше заказывать у хостинг-провайдера Хост.SU.

P.S. Если у Вас в системе установлен Perl, то для быстрой правки файла Вы можете выполнить всего лишь три команды:


perl -pi -e 's/mirrorlist=/#mirrorlist=/' /etc/yum.repos.d/CentOS-Base.repo
perl -pi -e 's/http://mirror.centos.org/https://vault.centos.org/' /etc/yum.repos.d/CentOS-Base.repo
perl -pi -e 's/#baseurl=/baseurl=/' /etc/yum.repos.d/CentOS-Base.repo

P.S.S. При наличии утилиты «sed» можно выполнить:


sed -i 's/mirrorlist=/#mirrorlist=/' /etc/yum.repos.d/CentOS-Base.repo
sed -i 's/http://mirror.centos.org/https://vault.centos.org/' /etc/yum.repos.d/CentOS-Base.repo
sed -i 's/#baseurl=/baseurl=/' /etc/yum.repos.d/CentOS-Base.repo

Одной из самых распространенных ошибок, с которыми пользователи 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.

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

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

This might be caused by two possibilities.

1. Repo too old to find

Base on your centos version, I tried to find the os via the link. And getting this information from readme file.

This directory (and version of CentOS) is deprecated. For normal users,
you should use /5/ and not /5.9/ in your path. Please see this FAQ
concerning the CentOS release scheme:

https://wiki.centos.org/FAQ/General

If you know what you are doing, and absolutely want to remain at the 5.9
level, go to http://vault.centos.org/ for packages. Please keep in mind that 5.9 no longer gets any updates

In this link, it suggest you to find old version via another link. Thus, you need to modify CentOS-Base.repo.

Replacing all http://mirror.centos.org/centos/*** into http://vault.centos.org/***.

for example:

Original: baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
New:      baseurl=http://vault.centos.org/$releasever/os/$basearch/

2. Network Issue

checking the mirrorlist server is accessible.

$ ping mirrorlist.centos.org

If you might meet the error message below.

ping: unknown host mirrorlist.centos.org

To solve this, adding a valid nameserver into resolv.conf (use sudo if you are not root user)

$ echo nameserver 8.8.8.8 > /etc/resolv.conf

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.

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 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?

Michael Mrozek's user avatar

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.

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 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?

Michael Mrozek's user avatar

asked Oct 19, 2011 at 9:14

shivshankar's user avatar

2

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

César HM's user avatar

answered Oct 23, 2011 at 20:01

Jorge's user avatar

JorgeJorge

1,7421 gold badge11 silver badges2 bronze badges

3

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

nnsense's user avatar

nnsense

3893 silver badges11 bronze badges

answered Apr 15, 2014 at 18:47

Raja David's user avatar

Raja DavidRaja David

3763 silver badges5 bronze badges

6

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

Anthon's user avatar

Anthon

77.8k42 gold badges164 silver badges221 bronze badges

answered Oct 3, 2013 at 12:25

Anand TS's user avatar

Anand TSAnand TS

1511 silver badge3 bronze badges

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

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

Greg's user avatar

answered May 26, 2013 at 23:09

Mastergalen's user avatar

MastergalenMastergalen

2522 silver badges7 bronze badges

1

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

nameserver 8.8.8.8
nameserver 8.8.4.4

ndemou's user avatar

ndemou

2,5791 gold badge19 silver badges27 bronze badges

answered Dec 4, 2011 at 7:03

ATUL KHACHANE's user avatar

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 https://www.getpagespeed.com/files/centos6-eol.repo --output /etc/yum.repos.d/CentOS-Base.repo

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

answered Jan 7, 2021 at 12:32

subtleseeker's user avatar

2

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.

ndemou's user avatar

ndemou

2,5791 gold badge19 silver badges27 bronze badges

answered May 4, 2012 at 17:16

victorkurauchi's user avatar

4

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.

slm's user avatar

slm

361k114 gold badges763 silver badges869 bronze badges

answered Feb 8, 2014 at 0:50

Mojo's user avatar

MojoMojo

1113 bronze badges

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 Oct 1, 2018 at 9:11

Elouan Keryell-Even's user avatar

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 Sep 6, 2018 at 22:04

grepit's user avatar

grepitgrepit

2132 silver badges6 bronze badges

2

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 Apr 4 at 21:18

Sinc's user avatar

SincSinc

1637 bronze badges

You must log in to answer this question.

Not the answer you’re looking for? Browse other questions tagged

.

Понравилась статья? Поделить с друзьями:
  • Ошибка cannot find 800x600x32 video mode как исправить
  • Ошибка can шины лансер 10
  • Ошибка cannot find 1536x864x32 video mode как исправить
  • Ошибка can шины лада веста
  • Ошибка cannot download the metalink and therefore the iso