Skip to content

Connection timed out to one target only: too specific route, gateway FAILED

Networkingtested on Ubuntu 24.04, iproute2 6.1.0, curl 8.5.0

The web server cannot be reached from the client, but the database at the same site can. That sounds like a problem on the web server – the measurement shows otherwise: there is a route for exactly this one target, and its gateway does not exist.

Symptom

sudo ip netns exec client curl -sS -m3 http://10.2.0.10/
curl: (28) Connection timed out after 3003 milliseconds

On the second call you get curl (7) Couldn't connect to server after about a second instead – same cause, different message. So do not search for the wording, measure.

Diagnosis

Ask which path the kernel takes for two targets in the same network.

sudo ip -n client route get 10.2.0.10
10.2.0.10 via 10.1.0.99 dev eth0 src 10.1.0.10 uid 0
    cache
sudo ip -n client route get 10.2.0.20
10.2.0.20 via 10.1.0.1 dev eth0 src 10.1.0.10 uid 0
    cache

Causes

/32 routeA more specific route beats the default route

The kernel always picks the route with the longest matching prefix: /32 beats /24, /24 beats the default route. A forgotten test route for a single address redirects only this target.

sudo ip -n client route
default via 10.1.0.1 dev eth0
10.1.0.0/24 dev eth0 proto kernel scope link src 10.1.0.10
10.2.0.10 via 10.1.0.99 dev eth0

FAILEDThe gateway does not answer ARP

The gateway 10.1.0.99 does not exist. The neighbour table is therefore FAILED – the packets never leave the client.

sudo ip -n client neigh show 10.1.0.99
10.1.0.99 dev eth0 FAILED

Fix

Remove the wrong route and prove with ip route get that the right gateway applies again.
sudo ip -n client route del 10.2.0.10/32
sudo ip -n client route get 10.2.0.10
10.2.0.10 via 10.1.0.1 dev eth0 src 10.1.0.10 uid 0
    cache

Don't: Look for the fault on the target host just because only that target is affected. First ask ip route get TARGET on the client.

▶
Break it yourself and find it – free
Network debugging, Day 2: route – default route, longest matching route, return path and policy routing.
Go to day 2 →

FAQ

Why does the database in the same network work but not the web server?

For 10.2.0.10 there is its own /32 route via a dead gateway; 10.2.0.20 still uses the default route. ip route get shows the difference per target.

What do STALE, FAILED and INCOMPLETE mean in ip neigh?

STALE is normal (not confirmed for a while). FAILED means nobody answered ARP; INCOMPLETE that the request is still running. FAILED and INCOMPLETE are what you look for.

Related error patterns

More