How to Solve Error Message curl# - “Failed to connect to ipv6 : Network is unreachable” upon installing package using yum utility in CentOS Operating System

Posted on

Introduction

This is an article where the focus of it is about how to solve an error message. The error message appear upon installing a package using yum utility. By the way, yum is a package manager utility program available usually in a Redhat linux operating system family for an example CentOS operating system. The following is an output of the command execution to show the error messages in detail :

[root@localhost ~]# yum search mariadb_server
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=genclo error was
14: curl#7 - "Failed to connect to xxxx:xxxx:xxx:xx::xx: Network is unreachable"
 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. Run the command with the repository temporarily disabled
            yum --disablerepo= ...
     4. Disable the repository permanently, 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 
        or
            subscription-manager repos --disable=
     5. 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=.skip_if_unavailable=true
Cannot find a valid baseurl for repo: base/7/x86_64
[root@localhost ~]#

The example of the package above is mariadb-server. Apparently, the connection to the repository address is pointing to the IP v6 format address. That format is actually appears in the following error message :

14: curl#7 - "Failed to connect to xxxx:xxxx:xxx:xx::xx: Network is unreachable"

Solution

The solution is quite simple. There are several alternatives which can be the proper solution. The following is the step for solving the solutions :

Disable IPv6

This is the first alternative solution. It is done by adding certain line for disabling the IPv6. Just do the following step :

1. Just add the following line to the configuration file of ‘/etc/sysctl.conf’. That line for disabling the IPv6 exist as follows :

net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
net.ipv6.conf.eth0.disable_ipv6 = 1

2. Try to restart the network service by executing the following command :

[root@localhost ~]# systemctl restart network
[root@localhost ~]# 

Modifying the yum package manager configuration

The following is the step for solving the problem for handling the error message if the previous step is not working. The steps are exist in the following :

1. Just configure yum to require another format of IP v4 only. Do it by changing the configuration of the yum package manager utility. Actually, the configuration of the yum package manager utility normally exist in ‘/etc/yum.conf’. Just open the file and add the following line :

ip_resolve=4

2. Don’t forget to retry installing the package by executing ‘yum search mariadb_server’. If it is the proper solution, the installation process will continue on.

 

Modifying the IPv4 Forward Configuration

If the previous step does not working at all, try to enable the IP v4 forwarding configuration. The following is the actual step to be able to do that :

1. Just edit the file responsible for the IPv4 forward configuration. The file is actually exist in ‘/proc/sys/net/ipv4/ip_forward’. But the modification of file itself cannot be done directly. Just execute the following command :

echo 1 > /proc/sys/net/ipv4/ip_forward

2. Don’t forget to check the content of the file by the execution of the following command :

[root@localhost ~]# cat /proc/sys/net/ipv4/ip_forward
1
[root@localhost ~]# 

Leave a Reply