NLB hairpinning
When a pod in your cluster calls an internal ingress hostname, some of its connections can time out. We fixed this, with no downtime, and you don’t need to do anything. This page explains why it happens, what we changed, and what we recommend for calls inside the cluster.
The problem
Your internal Ingresses are served by Traefik behind an internal AWS Network Load Balancer (NLB). A pod that calls one of their hostnames, like orders-api.production.eks.example.com, sends its request out of the cluster to the NLB, and the NLB sends it back in. This is called hairpinning.
With instance targets, every node in your cluster is registered as a target of the NLB, and the NLB sends each connection to one of them. If it picks the node the calling pod runs on, the connection times out. AWS documents this: hairpinning isn’t supported with client IP preservation, where the NLB passes the caller’s own IP to the node as the source. That’s the default for instance targets (AWS: Connections time out for requests from a target to its load balancer).
With N nodes, about 1 in N of these connections times out, so it looks like random timeouts. Your app sees a connect timeout, such as i/o timeout or context deadline exceeded, not an HTTP error. A retry on a new connection usually works. People connected through a VPN pod in your cluster (Tailscale, WireGuard) are affected the same way.
What we changed
We followed AWS’s advice: we turned off client IP preservation on the internal NLB’s TCP ports (instance targets only), with the target-group-attributes annotation of the AWS Load Balancer Controller. Traefik still sees the real client IP, because the NLB adds a PROXY protocol header: a small header at the start of each connection that carries the original client IP. Your Traefik access logs show the same client IPs as before. VPC Flow Logs (AWS’s network traffic logs) between the NLB and your nodes now show the NLB’s IP, so use the Traefik access logs for the client IP.
There is no downtime, and you don’t need to do anything. We roll it out to all clusters with our next release.
Recommended: call the Service inside the cluster
Even with the fix, a call through the ingress hostname still goes out to the NLB and back.
Tip
Best practice: inside the cluster, call the Service directly instead of the ingress hostname, unless one of the cases below applies.
Use <service>.<namespace>.svc.cluster.local:<port> instead of the hostname. For example, use http://orders-api.shop.svc.cluster.local:8080 instead of https://orders-api.production.eks.example.com. Find the Service port with kubectl get svc -n <namespace>. It has fewer hops and doesn’t depend on the NLB.
Note
This call skips Traefik, which is where HTTPS termination happens. The call travels as plain HTTP, unless your app serves TLS itself. The ingress path is no different after Traefik: the hop from Traefik to your app is plain HTTP too. The traffic stays inside your cluster’s private network and never crosses the internet. If you need it encrypted, for example for compliance, use a service mesh with mTLS (mutual TLS: both sides prove who they are with a certificate, and the traffic is encrypted). We offer Istio for this.
Keep the ingress hostname when:
- Your app logs in through an OIDC provider such as Dex. The issuer URL has to match the hostname.
- The call relies on Traefik middlewares like authentication, IP allowlists or rate limits. They only apply on the ingress path.
- Your app checks the hostname or redirects to its public URL, like WordPress does with its site URL.