52

I have set up a centOS 6.5 server using VMWare Workstation 9 on a Windows 8.1 host laptop. When trying to use yum to install packages I get the following error:

[root@localhost ~]# yum update
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
YumRepo Error: All mirror URLs are not using ftp, http[s] or file.
 Eg. </html>/
removing mirrorlist with no valid mirrors: /var/cache/yum/i386/6/base/mirrorlist.txt
Error: Cannot find a valid baseurl for repo: base

The VM works on other machines (Windows 7 desktop and an Windows 8.1 laptop), just not the one I need it to work on. I am able to ping the host from the guest and the guest from the host, so there is a connection to the internet.

I have uninstalled and reinstalled Workstation 9. Ungraded to workstation 10. Rebuilt the CentOS 6.5 server. Nothing seems to solve the issue.

When I upgraded from Windows 8 to Windows 8.1, I had VMWare installed. I found out later that I should have uninstalled VMWare before upgrading. Could this have messed up my VMWare network adapters?

Anyone have any ideas?

Keshava GN
  • 4,195
  • 2
  • 36
  • 47
TheJimmer
  • 521
  • 1
  • 4
  • 3

19 Answers19

71

Be sure that you can ping vault.centos.org.

Then edit /etc/yum.repos.d/CentOS-Base.repo

Comment out mirrorlist and uncomment baseurl

Change all

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

to

baseurl=http://vault.centos.org/$releasever/centosplus/$basearch/

And enjoy your yum update!!! ;)

mwfearnley
  • 3,303
  • 2
  • 34
  • 35
makidoo
  • 711
  • 5
  • 2
  • 16
    This *almost* worked for me, I noticed it was getting a 404 on http://vault.centos.org/5/ so I switched out $releasever for the actual version (5.11) and yum update works, thank you!! – Joe T Jun 09 '17 at 04:38
  • works great! same comment about using actual OS version (5.10 in my case) instead of $releaseserver – mbenhalima Feb 23 '19 at 00:04
  • Where is "/etc/yum.repos.d/CentOS-Base.repo"? – Hanh Nguyen Jan 29 '21 at 02:34
  • `cd /etc/yum.repos.d` and you should see. – dibery Feb 02 '21 at 03:32
  • 18
    A quick command to change: `sudo sed -i '/^mirrorlist/s/^/#/;/^#baseurl/{s/#//;s/mirror.centos.org\/centos\/$releasever/vault.centos.org\/6.10/}' /etc/yum.repos.d/*B*`. Remember to change `6.10` to your actual version (can be found `cat /etc/centos-release`). – dibery Feb 02 '21 at 03:34
  • Worked like a charm to me. @dibery, great shortcut! ;) – ciurlaro Feb 04 '21 at 11:17
  • 5
    The variable $releasever can also be specified in /etc/yum/vars/releasever: `echo "6.10" > /etc/yum/vars/releasever` – rbs Oct 11 '21 at 07:26
29

Centos 6 version met its EOL last month (November 30, 2020)

You can use one of the unofficial mirrors listed by centos in your /etc/yum.repos.d/CentOS-Base.repo. In my case (6.10) I used the mirror http://mirror.nsc.liu.se/centos-store/6.10/ and it worked smoothly:

[base]
name=CentOS-$releasever - Base
baseurl=http://mirror.nsc.liu.se/centos-store/6.10/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
# same for the others [updates] etc in the file
mateuszb
  • 1,072
  • 13
  • 26
20

I think another reason for this error message is if your release is no longer supported. None of the suggestions in this thread worked for me, and my internet connectivity was fine, but then I realized that I'm running Centos 5 (I know, ancient...) which reached its end-of-life on 2017 Mar 31 - right around when the yum repo error started showing up.

  • 3
    This is right. You must change the repo http url to 'vault'. The original 5* locations are no longer valid. – fcm Apr 30 '17 at 10:54
  • 2
    For those still looking -- you might want to try one of the mirrors listed on the Valut -> http://vault.centos.org/centos/. I found version 5.5 on the official mirror listed there. – Nux Sep 17 '19 at 13:41
12

for centos 5.4, you can change /etc/yum.repos.d/CentOS-Base.repo into like this.

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

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

#packages used/produced in the build but not released
[addons]
name=CentOS-5.4 - Addons
#mirrorlist=http://mirrorlist.centos.org/?release=5.4&arch=$basearch&repo=addons
baseurl=http://vault.centos.org/5.4/addons/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

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

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

#contrib - packages by Centos Users
[contrib]
name=CentOS-5.4 - Contrib
#mirrorlist=http://mirrorlist.centos.org/?release=5.4&arch=$basearch&repo=contrib
baseurl=http://vault.centos.org/5.4/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
lisency
  • 433
  • 1
  • 5
  • 9
  • This worked for me for 6.5, too. It was `baseurl=http://vault.centos.org/6.5/os/$basearch/` – sam Feb 25 '21 at 16:19
8

This happened to a system I support on a remote network and I determined it was due to the customer's Check Point firewall interfering with normal HTTP traffic. I ran a sudo tcpdump -nn -c 500 -s0 -X port 80 and watched yum get redirected to some kind of portal:

Location: http://x.x.x.x/UserCheck/PortalMain?....

Funny thing is, it was hard to reproduce with curl, which retrieved the mirror list without any problem. I found I had to add the User-agent: urlgrabber/3.1.0 yum/3.2.22 HTTP header that yum uses to trigger Check Point interfering, like this:

$ curl -i \
    -H 'User-agent: urlgrabber/3.1.0 yum/3.2.22' \
    'http://108.61.16.227/?release=5&arch=x86_64&repo=os'
HTTP/1.1 307 Temporary Redirect
Location: http://x.x.x.x/UserCheck/PortalMain?IID=....origUrl=....
Connection: close

Googling for UserCheck/PortalMain shows this is Check Point Firewall. And the IP I obscured there (x.x.x.x) belonged to the customer. This was sufficient proof to tell the customer he needed to make some kind of change to his firewall to allow my system unobstructed internet access (I have no idea what, but I hope he and/or his network team can figure it out).

Steve Kehlet
  • 6,156
  • 5
  • 39
  • 40
  • While it didn't do it before... this happened to me with our Barracuda Webfilter since the nagios system was not authenticating with domain credentials. A simple exception got me working again. Thanks. – Matt Nov 22 '16 at 13:38
7

Adding the following before yum update -y helped me to fix the problem:

yum clean all
echo "http://vault.centos.org/5.11/os/x86_64/" > /var/cache/yum/base/mirrorlist.txt
echo "http://vault.centos.org/5.11/extras/x86_64/" > /var/cache/yum/extras/mirrorlist.txt
echo "http://vault.centos.org/5.11/updates/x86_64/" > /var/cache/yum/updates/mirrorlist.txt

BTW, CentOS 5 had already reached EOL

Sudheesh.M.S
  • 498
  • 1
  • 7
  • 13
4

CentOS 6.10 after 2021-01-15

CentOS-Base.repo

[base]
name=CentOS-$releasever - Base
baseurl=https://vault.centos.org/6.10/os/$basearch/
gpgcheck=1
gpgkey=https://vault.centos.org/6.10/os/$basearch//RPM-GPG-KEY-CentOS-6

CentOS-fasttrack.repo

[fasttrack]
name=CentOS-6 - fasttrack
baseurl=https://vault.centos.org/6.10/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://vault.centos.org/6.10/$basearch/RPM-GPG-KEY-CentOS-6

CentOS-SCLo-scl.repo

# CentOS-SCLo-sclo.repo
#
# Please see http://wiki.centos.org/SpecialInterestGroup/SCLo for more
# information

[centos-sclo-sclo]
name=CentOS-6 - SCLo sclo
baseurl=https://vault.centos.org/6.10/sclo/$basearch/sclo/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo

[centos-sclo-sclo-testing]
name=CentOS-6 - SCLo sclo Testing
baseurl=https://vault.centos.org/6.10/sclo/$basearch/sclo/
gpgcheck=0
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo

[centos-sclo-sclo-source]
name=CentOS-6 - SCLo sclo Sources
baseurl=https://vault.centos.org/6.10/sclo/$basearch/sclo/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo

[centos-sclo-sclo-debuginfo]
name=CentOS-6 - SCLo sclo Debuginfo
baseurl=https://vault.centos.org/6.10/sclo/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo
Intacto
  • 527
  • 3
  • 8
4
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo_old

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


[base]
name=CentOS-$releasever - Base
baseurl=http://vault.centos.org/6.9/os/$basearch
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
exclude=redhat-logos

yum clean all

yum update -y 

Enjoy!!!!
Ali Raza
  • 174
  • 1
  • 3
3

In the same vein as the other posts regarding the updates to /etc/yum.repos.d/CentOS-Base.repo, I additionally had to modify the baseurl values in the following files:

sudo vi /etc/yum.repos.d/CentOS-SCLo-scl.repo
sudo vi /etc/yum.repos.d/CentOS-SCLo-scl-rh.repo

You might want to ls /etc/yum.repos.d/ and look over the contents of any other files in there which might need updating for an EOL distro version.

Also, but sure to clear the yum cache with sudo yum clean all.

BuvinJ
  • 10,221
  • 5
  • 83
  • 96
3

CENTOS 6.10

  • Backup File /etc/yum.repos.d/CentOS-Base.repo
  • After backup edit file and copy the following content:
[base]

name=CentOS-$releasever - Base

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

gpgcheck=1

gpgkey=https://vault.centos.org/6.10/os/$basearch//RPM-GPG-KEY-CentOS-6

#released updates 

[updates]

name=CentOS-$releasever - Updates

baseurl=https://vault.centos.org/6.10/updates/$basearch/

gpgcheck=1

gpgkey=https://vault.centos.org/6.10/updates/$basearch//RPM-GPG-KEY-CentOS-6


#additional packages that may be useful

[extras]

name=CentOS-$releasever - Extras

baseurl=https://vault.centos.org/6.10/extras/$basearch/

gpgcheck=1

gpgkey=https://vault.centos.org/6.10/extras/$basearch//RPM-GPG-KEY-CentOS-6

#additional packages that extend functionality of existing packages

[centosplus]

name=CentOS-$releasever - Plus

baseurl=https://vault.centos.org/6.10/centosplus/$basearch/

gpgcheck=1

gpgkey=https://vault.centos.org/6.10/centosplus/$basearch//RPM-GPG-KEY-CentOS-6


#contrib - packages by Centos Users

[contrib]

name=CentOS-$releasever - Contrib

baseurl=https://vault.centos.org/6.10/contrib/$basearch/

gpgcheck=1

gpgkey=https://vault.centos.org/6.10/contrib/$basearch//RPM-GPG-KEY-CentOS-6
sɐunıɔןɐqɐp
  • 3,332
  • 15
  • 36
  • 40
TRV
  • 31
  • 1
2

The answer from @Steve Kehlet above got me on the correct path after finding this Q&A searching for the same symptom. More generally though, the answer turns out to be any sort of filtering web proxy (frequently employed within Corp environments) can cause this when it redirects yum's "http" request. In many of these cases, vendors provide a "web proxy" of some sort (specific to each particular firewall/filtering implementation - ask your sysadmins).

The important part not mentioned in this answer so far is, you can make CentOS yum work with this proxy, by adding the following line to /etc/yum.conf

proxy=http://proxy.yoursite.whatever:port_num

This will let yum know how to work with your company's proxy, and fix the unintuitive "All mirror urls are not using..." error

JesseM
  • 191
  • 4
  • 7
1

I faced the same problem with CentOS 5.11 and here complete solution file I ended up with :-

nano /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
# http://vault.centos.org/5.11/
# http://vault.centos.org/5.11/updates/
# 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
baseurl=http://vault.centos.org/5.11/centosplus/$basearch/

gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5


#released updates 
[updates]
name=CentOS-$releasever - Updates

baseurl=http://vault.centos.org/5.11/updates//$basearch/

gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5


#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras

#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
baseurl=http://vault.centos.org/5.11/extras/$basearch/


gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

#additional packages that extend functionality of existing packages


[centosplus]
name=CentOS-$releasever - Plus
baseurl=http://vault.centos.org/5.11/centosplus/$basearch/


gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
#baseurl=http://mirror.centos.org/centos/$releasever/contrib/$basearch/

gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
Salem
  • 654
  • 7
  • 24
1

For anybody else stuck in the past,

From within a docker container centos:centos5

# cat CentOS-Base.repo
[base]
name=CentOS-5.11 - Base
#mirrorlist=http://mirrorlist.centos.org/?release=5.11&arch=$basearch&repo=os
baseurl=http://archive.kernel.org/centos-vault/5.11/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

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

#packages used/produced in the build but not released
[addons]
name=CentOS-5.11 - Addons
#mirrorlist=http://mirrorlist.centos.org/?release=5.11&arch=$basearch&repo=addons
baseurl=http://archive.kernel.org/centos-vault/5.11/addons/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

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

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

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

I had to also change this libselinux.repo

# cat libselinux.repo
[libselinux]
name=CentOS-$releasever - libselinux
baseurl=http://archive.kernel.org/centos-vault/5.11/os/$basearch/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
includepkgs=libselinux*
amacvar
  • 311
  • 3
  • 8
1

Here we need to only put correct baseurl in /etc/yum.repos.d/CentOS-Base.repo

check this URL http://mirror.cisp.com browse your OS and take that URL

If you have Centos6.10 then your baseurl as follow

baseurl=http://mirror.cisp.com/CentOS/6.10/

1
  1. vim /etc/yum.repos.d/myrepo.repo
  2. Paste these lines:
[centos]
name=CentOS-6.10 - Base
baseurl=http://mirror.nsc.liu.se/centos-store/6.10/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
  1. save file and exit.
  2. yum repolist.
  3. yum install nmap
0

Check if you are able to ping an externals site such as www.google.com. If not insert lines:

nameserver 208.67.222.222
nameserver 208.67.220.220

in /etc/resolve.conf

Also in /etc/yum.repos.d/CentOS-Base.repo

uncommented all the mirrorlist and comment out all the baseurl

If mirrorlist doesn't work for you you can try only the baseurl.

Hope it helps!!

Amar
  • 2,171
  • 1
  • 13
  • 16
  • Thank you Amar, but your suggestions did not solve the issue. I get the same error. I have been able to ping external sites like google.com so I did not add the name servers. Should I do that even though I can ping external sites? – TheJimmer Jan 29 '14 at 23:07
  • If you are able to reach the external sites then either of baseUrl or mirrorList will work for you. Try to reach the link that yum tries to open from a browser.Are you able to access it? – Amar Feb 11 '14 at 13:09
0

There are two things you can do:

  1. Go to /etc/sysconfig/network-scripts/ and verify your interface file, ifcfg-eth0 for example. Change "NM_CONTROLLED" from "yes" to "no". Restart network.
  2. Go to /etc/sysconfig/network-scripts/ and edit ifcfg-eth0. Add DNS1=8.8.8.8 and DNS2=. First entry is Google Public DNS. Restart network.

One of these should fix your issue.

Also, if you didn't do this yet, go back to original /etc/yum.repos.d/CentOS-Base.repo file.

lkhudisman
  • 89
  • 1
0

Comment out metadata_expire directive in /etc/yum.conf and do yum clean all. This worked for me. Not sure how.

0

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

  • Answer

If you see the above error means first you need to check the internet is working or not (ping 8.8.8.8) , if the internet is working means you can debug otherwise check your firewall and get the internet.

john3
  • 1