No route to host


New Member
Oct 21, 2022
Reaction score
I have a CentOS 7 system (no GUI) and logging in with ssh (Putty) from a Windows system. When I log in two IPs are listed, i.e.

IP Address:
IP Address:

The connection I established is through the address which I set to DHCP. There is a second network adapter in the system which seems to be that address. I did a "sudo yum install apt" but that produced the error: [Errno 14] curl#7 - "Failed connect to; No route to host" Trying other mirror.

For some reason it tried to use that address. That's despite the fact that when I do a nmcli d that other network interface is listed as unavailable. I even did a sudo ifdown enp0x31f7. So how can I make CentOS to use the address? And is that 8765 port causing some additional issues?

Note that I am a complete Linux beginner.

Moving this to Linux Networking

Chris Turner
Most likely your Host settings are incorrect. Check your /etc/hosts file entries, may be the URL which You're requesting, is pointing to your localhost. It is showing "curl#7-failed to connect"
If the URL is not listed in your /etc/hosts file, then try to execute following command to understand the flow of Curl Execution for the particular URL:
curl --ipv4 -v "";
The entries in /etc/hosts are localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6

The issue seems to be that "sudo yum install apt" is trying to access "" but the address is invalid. I think (not sure) it should be, i.e. the IP address of the computer on which I execute this command.
When you have two interfaces, (which are typically on two different subnets)
You need to have a default gateway. Usually you will only have a default gateway on one of these two interfaces.

What is the output of netstat -nr

One of your interfaces should have a destination of
If both do, then you have to set a route priority.
Give interface 1 a lower priority number than interface 2 if interface 1 is the one going out to the internet.


For example traffic will try to go out an interface with a priority of 1 before it will try to go an interface of 50.
You can use negative numbers. -999 above means try to go through this interface before any other.
netstat -nr shows the following:

Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface UG 0 0 0 enp0s31f6 U 0 0 0 enp0s31f6

enp0x31f6 seems to be correct as nmcli d give me

enp0s31f6 ethernet connected enp0s31f6
enp0s31f7 ethernet unavailable --
lo loopback unmanaged --

So I don't get where this address is coming from in [Errno 12] Timeout on http://192.1 68.10.4:8765/repodata/repomd.xml: (28, 'Connection timed out after 5001 millisec onds')
Trying other mirror.

My config file for this network adapter is below. I think it listed an IP address before but I removed that and did a systemctl restart network.

CentOS 7. Been a while since I've used that. Just about forgotten about ifcfg files.
If you're using network-manager you really don't even need the ifcfg files.

What is output of

ip addr


nmcli con show
Here is what ip addr and nmcli con show prints

[[username]@[IP] ~]$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: enp0s31f7: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN group default qlen 1000
link/ether 00:04:5f:44:24:31 brd ff:ff:ff:ff:ff:ff
3: enp0s31f6: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:04:5f:44:a3:cd brd ff:ff:ff:ff:ff:ff
inet brd scope global noprefixroute dynamic enp0s31f6
valid_lft 683867sec preferred_lft 683867sec
inet6 fe80::a37b:b1e8:5e0a:9a20/64 scope link noprefixroute
valid_lft forever preferred_lft forever
[[username]@[IP] ~]$ nmcli con show
enp0s31f6 [UUID1] ethernet enp0s31f6
Wired connection 1 [UUID2] ethernet --
enp0s31f7 [UUID3] ethernet --
When I log in two IPs are listed, i.e.

IP Address:
IP Address:

Hmmm... where are you seeing this?
"sudo yum install apt"

I doubt apt is in any default CentOS repo. Perhaps you have created another repo file? [Errno 12] Timeout on http://192.1 68.10.4:8765/repodata/repomd.xml: (28, 'Connection timed out after 5001 millisec onds')

I should have read this part better before.

Can you give output of ...

grep enabled /etc/yum.repos.d/*repo

Normally you get the error above from a repo server.
The two lines of "IP Address: ..." were listed before I disabled the second network card. Now when logging in via ssh it only shows on IP:

CentOS Linux release 7.5.1804 (Core)
Kernel 3.10.0-693.21.1.rt56.639.el7.x86_64
Revision B

System information as of: Wed Oct 26 22:48:01 GMT 2022

IP Address:
System load: 0.00
Memory usage: 3.5%
System uptime: 1 day, 53 minutes
Usage on /: 20%
Local Users: 1
Processes: 217

Below is what the grep shows.

How about ...

grep 192.168.10 /etc/yum.repos.d/*repo



You may have to try that command without the S or in lower case.
That gives me

[...@... ~]$ grep 192.168.10 /etc/yum.repos.d/*repo
[...@... ~]$ echo $HTTPS_PROXY

And here is that 192 IP but I am not sure what those repo files are and how an IP in there makes this a default IP to go out to the internet.

[...@... yum.repos.d]$ cat [Company]Install.repo
name=[Company] Install Repo
In that company repo file.
Change the enabled = 1 to enabled = 0.
It won't hurt anything because it's not a default vendor repo.
If it turns out, you do need it, you can always re-enable it later.

Then do a
yum clean all

Then try to search or install something.
yum install lsof

It should work now.
I did set enabled=0 and then

[...@... yum.repos.d]$ yum clean all
There are no enabled repos.
Run "yum repolist all" to see the repos you have.
To enable Red Hat Subscription Management repositories:
subscription-manager repos --enable <repo>
To enable custom repositories:
yum-config-manager --enable <repo>

What is confusing is that it talks about Red Hat when I have CentOS 7.5.1804 (Core). Maybe CentOS is based on Red Hat.

I then did a "sudo yum install lsof" as well as "sudo yum install libssl-dev" but both gave me the same message as above, i.e. There are no enabled repos. When I execute the yum repolist all I get a long list with everything set to disabled. I put the output in an attachment as the list is pretty long. I did some googling on this but everything seems to refer to Red Hat and I don't want to mess up the system by doing something wrong.


  • output1.txt
    5.9 KB · Views: 220
Yes CentOS, AlmaLinux, OracleLinux, ScientificLinux, RockyLinux, and a few others are Based on Redhat.
Which is itself based on Fedora.

I would enable the CentOS repos, and probably the epel repo's also.
But leave the "Company" repo disabled.
I am running into other troubles but enabling all the CentOS (except the media one) and epel repos did the trick. No I don't get that error with the 192 IP address anymore and it seems it did indeed download packages from the internet. Thanks a lot for the help!!!
If you were helped to satisfaction, you can edit your first post and change the headline to say [SOLVED] (or similar).

Staff online

Members online

Latest posts