How to fix connect: no route to host in Kubernetes
Network packets cannot reach the destination host because network policies block traffic, IP forwarding is disabled on nodes, or pods are isolated by CNI configuration. Unlike connection refused, the packet never reaches the application. Fix by reviewing network policies, enabling IP forwarding, or configuring CNI correctly.
Quick fix
Fixes connect: no route to host
kubectl get networkpolicies -A
kubectl describe networkpolicy <name> -n <namespace>- Check network policies are permissive
- Verify IP forwarding is enabled on nodes
- Check CNI plugin is running
- Verify pod CIDR ranges don't conflict
kubectl get networkpolicies -Akubectl describe networkpolicy <name> -n <namespace>connect: no route to host
What this error means
This error indicates the network cannot route packets to the destination. In Kubernetes, it commonly occurs when: network policies deny inter-pod traffic, nodes have IP forwarding disabled, pod CIDR ranges conflict, or the CNI plugin is misconfigured. The packets are dropped at the network layer before reaching the pod.
Typical symptoms
- Connection hangs indefinitely, no "refused" message
- Traffic stops at node boundary
- Works within same node but not cross-node
- Network policy exists with restrictive rules
- IP forwarding disabled on nodes
- Pod CIDR conflicts with host network
Common causes
- Network policy denying egress or ingress traffic
- IP forwarding disabled on nodes (echo 1 > /proc/sys/net/ipv4/ip_forward)
- Pod CIDR range conflicts with node network
- CNI plugin not properly initialized
- Firewall on host or cloud network blocking traffic
- Pod security policies restricting network access
- Cross-cluster networking not configured
How to fix "connect: no route to host"
List all network policies:
kubectl get networkpolicies -A
kubectl describe networkpolicy <name> -n <namespace>Network policies default to DENY if namespace is in deny-all mode. To allow all traffic:
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: allow-all
spec:
podSelector: {}
policyTypes:
- Ingress
- Egress
ingress:
- {}
egress:
- {}SSH to node and check IP forwarding:
sudo sysctl net.ipv4.ip_forward
# Should return: net.ipv4.ip_forward = 1If 0, enable it:
sudo sysctl -w net.ipv4.ip_forward=1
# Make persistent:
sudo echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf
sudo sysctl -pVerify CNI pods are running on all nodes:
kubectl get daemonset -n kube-system
kubectl get pods -n kube-system -o wide | grep -E "(weave|flannel|calico|cilium)"Ensure DaemonSet has desired = current = ready count for all nodes. If not, check node taints and tolerations.
Check cluster CIDR and node pod CIDR allocations:
kubectl cluster-info dump | grep -i cidr
kubectl get nodes -o wide
# Check node allocatable IPs:
kubectl describe node <node-name> | grep -A2 "Allocated resources"Ensure pod CIDR doesn't overlap with node network or other services.
SSH into one node and test reachability:
ssh node1
ping <pod-ip-on-node2>
ping <service-ip>If pings fail, the network layer has issues. Check iptables and routes on nodes.
On cloud platforms (AWS, Azure, GCP), check security groups:
# AWS
aws ec2 describe-security-groups --query 'SecurityGroups[?GroupName=='default']'
# Azure
az network nsg list --query "[].{Name:name, ResourceGroup:resourceGroup}"Ensure ingress/egress allow pod and service CIDR ranges.
Capture packets on source and destination nodes:
sudo tcpdump -i any -nn src <pod-ip-1> or dst <pod-ip-1> -w capture.pcap
# Then analyze with Wireshark or tcpdump
sudo tcpdump -r capture.pcapLook for packets arriving at destination node interface.
Advanced notes
This error is network-layer (layer 3), unlike "connection refused" which is application-layer. Cross-node communication is critical in Kubernetes; most CNI plugins (Flannel, Weave, Calico) handle routing automatically. In on-premises clusters, ensure all nodes are on same L2 network or routing is configured. For multus (multiple network interfaces), ensure routes are correct for secondary networks. Cilium offers advanced networking debugging: cilium connectivity test.
Frequently asked questions
- What does "connect: no route to host" mean?
- This error indicates the network cannot route packets to the destination. In Kubernetes, it commonly occurs when: network policies deny inter-pod traffic, nodes have IP forwarding disabled, pod CIDR ranges conflict, or the CNI plugin is misconfigured. The packets are dropped at the network layer before reaching the pod.
- How do I fix "connect: no route to host"?
- Network packets cannot reach the destination host because network policies block traffic, IP forwarding is disabled on nodes, or pods are isolated by CNI configuration. Unlike connection refused, the packet never reaches the application. Fix by reviewing network policies, enabling IP forwarding, or configuring CNI correctly.
- What causes "connect: no route to host"?
- Network policy denying egress or ingress traffic IP forwarding disabled on nodes (echo 1 > /proc/sys/net/ipv4/ip_forward) Pod CIDR range conflicts with node network
- Is the "connect: no route to host" error serious?
- Yes. This is a high-severity error that usually blocks work until it is fixed, but the steps above resolve it.
Official resources & further reading
- ๐Kubernetes Official Documentation
- ๐Kubernetes Docs: network policies(Official Docs)
- ๐Kubernetes Docs: network policy provider(Official Docs)
- ๐
- ๐