What the Message Means
Envoy stands between clients and backend services, which it calls upstreams. When it cannot get a response from the upstream, it answers the client itself with status 503 and a short text body:
upstream connect error or disconnect/reset before headers. reset reason: remote connection failure
"Before headers" is the key part: the backend never started an answer. Either the connection could not be opened, or it was closed or reset before the first response line arrived. After retries the text says "retried and the latest reset reason", and it can end with a transport failure reason, for example a TLS error.
Read the Reset Reason
- connection failure: Envoy could not open a TCP connection. Current releases write "remote connection failure", "local connection failure", or "connection timeout"; older ones wrote "connection failure". Nothing listens on that address and port, or a network policy blocks it.
- connection termination: the connection opened, then the backend closed it. A crash, a protocol mismatch, or an idle connection closed at the wrong moment.
- remote reset: the backend reset the connection or the stream.
- local reset: Envoy reset it itself, for example on a timeout.
- overflow: a connection or request limit in Envoy, a circuit breaker, was reached.
- protocol error: the backend's reply broke the HTTP protocol Envoy expected.
Envoy's access log adds short response flags for the same events; for example UF marks an upstream connection failure, UC a connection termination, and UO an overflow, each with a 503.
What a Visitor Can Do
Reload after a short wait. The cause is always between the proxy and the service behind it, so the operator has to fix it.
Cause: The Backend Is Not Listening
- Crashed or restarting: in Kubernetes,
kubectl get podsshows restarts, andkubectl logs pod-name --previousshows the log of the run that died. - Listening on the loopback address only: an application inside a container that binds to 127.0.0.1 cannot be reached from the proxy. It must listen on all interfaces.
ss -ltnpinside the container shows the address. - Killed for memory: see exit code 137.
Cause: Wrong Port or Not Ready
The service definition must send traffic to the port the container really uses. In Kubernetes, compare the service's target port with the container port, and check that the service has endpoints:
kubectl get endpoints my-service
kubectl describe pod my-pod
No endpoints usually means a failing readiness probe or a label selector that matches no pods. See the kubectl cheat sheet.
Cause: Protocol Mismatch
Envoy has to know what the backend speaks. HTTP/2 sent to an HTTP/1.1-only server, plain text sent to a TLS port, or TLS sent to a plain port all end before headers. In a mesh, the port name or the declared application protocol decides this, and mutual TLS settings must match on both sides.
Cause: Idle Connections and Limits
Envoy keeps connections to backends open and reuses them. If the backend closes idle connections sooner than Envoy expects, a request can be sent on a connection that is closing. Make the backend's idle timeout longer than Envoy's, and allow retries for requests that are safe to repeat. An overflow reason means the limits in Envoy's configuration are too low for the traffic, or the backend is too slow to keep up. The general mechanism is in connection reset by peer.
Test from Inside the Network
Call the backend directly, without Envoy, from a pod or host on the same network:
kubectl run debug --rm -it --image=curlimages/curl -- sh
curl -v http://my-service:8080/health
If this fails too, the problem is the backend or the network, not the proxy. If it works, compare the proxy's settings for that route: port, protocol, and TLS.
Related Errors
The same situation in other proxies shows up as 502 Bad Gateway or 503 Service Unavailable. How a proxy fits between clients and services is explained in what is a reverse proxy.