Envoy Gateway Requests Timing Out After 15 Seconds: HTTPRoute and BackendTrafficPolicy
A backend can still be processing a request when the gateway returns 504 Gateway Timeout. If the response body says upstream request timeout and requests repeatedly fail after roughly the same duration, check the limits along the request path before restarting Pods.
Some APIs may still time out early after you increase the shared Gateway limit. An explicit HTTPRoute value or a more specific policy can make the shared change ineffective. This post shows how to find that value and adjust the timeout only where it is needed.
The baseline is Envoy Gateway v1.9.0. Installation and Gateway configuration are covered in Envoy Gateway Setup; this post focuses on timeouts along an already working HTTP path.
Symptoms: which layer ended the request first?
Section titled “Symptoms: which layer ended the request first?”The client, gateway, and backend can each end a request. Seeing continued processing in backend logs does not establish that the rest of the path is healthy.
| What to inspect | What to look for |
|---|---|
| Client output | An HTTP 504 versus the client exiting without an HTTP response |
| Gateway access log | Status code and timeout-related details for the same request |
| Backend logs | Whether it received the request and when it completed the response |
| A call bypassing the gateway | Whether the backend itself fails after the same duration |
Envoy Proxy’s default Route timeout is 15 seconds. This is not a universal Gateway API default. Gateway API leaves behavior for unspecified timeouts to the implementation.
Figure 1. More than one layer can end a request. Original diagram based on Envoy’s timeout explanation and Istio’s request timeout explanation.
There is more than one timeout
Section titled “There is more than one timeout”A limit on total request duration differs from a limit on the time without data. Connection establishment has its own limit too.
| Setting | What it limits |
|---|---|
HTTPRoute.rules[].timeouts.request | Total time for the gateway to process a request and send its response |
HTTPRoute.rules[].timeouts.backendRequest | An individual request from the gateway to a backend |
BackendTrafficPolicy.spec.timeout.http.requestTimeout | The policy’s limit for completing the upstream response |
BackendTrafficPolicy.spec.timeout.tcp.connectTimeout | Establishing the backend connection |
BackendTrafficPolicy.spec.timeout.http.streamIdleTimeout | Time without request or response data on a stream |
BackendTrafficPolicy.spec.timeout.http.maxStreamDuration | Maximum lifetime of a stream |
request and backendRequest are not alternate spellings of the same setting. With retries, one overall request can contain several backend requests. When both values are finite, backendRequest cannot exceed request.
In v1.9.0, processRouteTimeout uses backendRequest as the final Route timeout when it is set on a rule without retries. To avoid mixing these cases, the ordinary API examples here set only request.
If you are coming from Istio
Section titled “If you are coming from Istio”The official AKS Istio add-on ingress example uses Istio’s Gateway and VirtualService. The names resemble Envoy Gateway’s Gateway API resources, but their API groups differ.
| Item | Envoy Gateway | AKS Istio ingress using Istio APIs |
|---|---|---|
| Gateway resource | Gateway in gateway.networking.k8s.io | Gateway in networking.istio.io |
| HTTP routing | HTTPRoute | VirtualService |
| Request timeout | HTTPRoute timeouts or BackendTrafficPolicy | VirtualService.http[].timeout |
| Default request limit | Envoy Route default of 15 seconds | Disabled by default in the Istio documentation |
Both use Envoy, but the controlling products apply different defaults. Having no explicit timeout in Istio does not mean an Envoy Gateway route will have no limit.
The equivalent Istio setting looks like this. The slow-api Service and ingress Gateway are assumed to exist already.
apiVersion: networking.istio.io/v1kind: VirtualServicemetadata: name: slow-apispec: hosts: - timeout.example.com gateways: - ingress-gateway http: - route: - destination: host: slow-api port: number: 3000 timeout: 30sThis comparison covers request limits for ingress using Istio APIs. For AKS add-on installation and mesh policies, see the official AKS ingress guide.
Adjust a specific API with HTTPRoute
Section titled “Adjust a specific API with HTTPRoute”Assume Gateway eg and a delay-capable Service named backend exist in the default namespace. This is the same kind of backend used in Envoy Gateway’s official timeout guide. Set GATEWAY_URL to the HTTP address through which you can reach the Gateway.
The following Route allows four seconds for the request.
apiVersion: gateway.networking.k8s.io/v1kind: HTTPRoutemetadata: name: slow-api namespace: defaultspec: parentRefs: - name: eg hostnames: - timeout.example.com rules: - matches: - path: type: PathPrefix value: / backendRefs: - name: backend port: 3000 timeouts: request: "4s"kubectl apply -f slow-api-route.yamlcurl -sS -i --max-time 10 \ -H 'Host: timeout.example.com' "$GATEWAY_URL/?delay=3s"A three-second response delay is shorter than the four-second limit, so the request should succeed. Reducing the limit to two seconds lets you observe a gateway timeout.
kubectl patch httproute slow-api -n default --type=json \ -p '[{"op":"replace","path":"/spec/rules/0/timeouts/request","value":"2s"}]'After the change, the official guide’s expected response for the same request is:
HTTP/1.1 504 Gateway Timeout...upstream request timeoutIf curl --max-time is shorter than the gateway limit, the client exits first and hides this behavior. The example sets it to ten seconds to distinguish the two limits.
Shared defaults and exceptions with BackendTrafficPolicy
Section titled “Shared defaults and exceptions with BackendTrafficPolicy”Set a shared value on the Gateway
Section titled “Set a shared value on the Gateway”Attach a policy to the Gateway when several Routes need a shared limit. This example sets a 60-second request limit for Routes attached to eg.
apiVersion: gateway.envoyproxy.io/v1alpha1kind: BackendTrafficPolicymetadata: name: gateway-timeout namespace: defaultspec: targetRefs: - group: gateway.networking.k8s.io kind: Gateway name: eg timeout: http: requestTimeout: 60sSet an exception on the Route
Section titled “Set an exception on the Route”For a 30-second limit on slow-api alone, target that HTTPRoute with a separate policy.
apiVersion: gateway.envoyproxy.io/v1alpha1kind: BackendTrafficPolicymetadata: name: slow-api-timeout namespace: defaultspec: targetRefs: - group: gateway.networking.k8s.io kind: HTTPRoute name: slow-api timeout: http: requestTimeout: 30sA policy must be in the same namespace as its target. Both the Gateway and HTTPRoute above are in default, so both policies belong there too. If the application Route is in another namespace, create its Route-targeted policy in that namespace.
Precedence is not automatic merging
Section titled “Precedence is not automatic merging”More specific scopes take precedence: Route rule, Route, Gateway listener, then the whole Gateway. This post covers HTTPRoutes attached directly to a Gateway.
Without mergeType, the most specific policy is selected without automatically merging it with its parent. A Route policy containing only a timeout does not necessarily retain the Gateway policy’s other limits. If parent configuration must be combined, check the behavior of StrategicMerge or JSONMerge too.
Figure 2. PlantUML activity diagram generated from timeout-precedence.puml. An explicit HTTPRoute value ends the selection before the policy request limit is considered. Policy scopes and mergeType are explained in the note below the flow. Original diagram based on the BackendTrafficPolicy documentation and the v1.9.0 translator code.
When the HTTPRoute already has a value
Section titled “When the HTTPRoute already has a value”The earlier example set timeouts.request: "2s" on slow-api. While that value remains, applying the policies above does not change the request limit to 30 seconds.
In v1.9.0, getEffectiveRequestTimeout first uses the timeout translated from HTTPRoute. Only if that value is absent does it use the selected BackendTrafficPolicy’s request timeout. The same release’s timeout test output shows a final value of ten seconds when HTTPRoute specifies ten and the policy specifies five.
To manage the value through policies, remove timeouts from the Route before applying them.
kubectl patch httproute slow-api -n default --type=json \ -p '[{"op":"remove","path":"/spec/rules/0/timeouts"}]'kubectl apply -f gateway-timeout-policy.yamlkubectl apply -f route-timeout-policy.yamlA controller generating Routes may put the field back. Adjust its generation settings or consider changing the Route’s owner, as described in Managing KServe HTTPRoutes.
If requests still time out: inspect the actual Envoy configuration
Section titled “If requests still time out: inspect the actual Envoy configuration”First inspect the accepted Kubernetes resources and their status conditions.
kubectl get httproute slow-api -n default -o yamlkubectl get backendtrafficpolicy -n default -o yamlCheck Accepted and ResolvedRefs in HTTPRoute’s status.parents[].conditions, then read the policy conditions too. Confirm the target name, namespace, and kind, and whether observedGeneration reflects the resource’s current generation. A successful kubectl apply is not proof of data-plane application.
Next use the matching version of egctl to read the actual Envoy Route configuration.
egctl config envoy-proxy route | jq ' .. | objects | select(.match? != null and .route? != null) | { name, timeout: .route.timeout, idleTimeout: .route.idleTimeout, maxStreamDuration: .route.maxStreamDuration }'The list includes internal management Routes, so locate the relevant HTTPRoute using name. A null timeout means the field was omitted from the dump, not that the limit is disabled. Distinguish an explicit 0s from use of the default.
The following are expected behaviors based on the official delayed-response example and v1.9.0 source.
| Condition | Expected behavior |
|---|---|
| No request timeout configured, response takes 20 seconds | Hits Envoy’s default 15-second request limit |
HTTPRoute request: 4s, response takes 3 seconds | Success |
HTTPRoute request: 2s, response takes 3 seconds | Gateway timeout |
| No HTTPRoute timeout, Gateway policy specifies 60 seconds | Final request limit of 60 seconds |
| No HTTPRoute timeout, Gateway policy specifies 60 and Route policy specifies 30 seconds | Route policy’s 30 seconds |
HTTPRoute request: 4s, policy request limit of 30 seconds | HTTPRoute’s four seconds |
| Gateway limit of 30 seconds, client limit of 10 seconds | Client exits first |
If configuration and actual behavior disagree, compare application-server, additional proxy, and client limits for the same request.
Long AI requests and streaming
Section titled “Long AI requests and streaming”An inference API that returns one complete response and a streaming API that sends tokens incrementally often need different policies.
Envoy’s Route timeout starts after the entire downstream request is received and limits the time until the upstream response completes. A response can therefore keep streaming yet still hit the overall limit. An endless streaming request has a different timer start condition, so check maxStreamDuration and idle limits instead.
Two limits can be separated for streaming APIs:
streamIdleTimeoutcleans up a stream without further data. If data keeps arriving, this limit alone does not bound its total duration.maxStreamDurationlimits the entire stream even while data continues to arrive.
For example, if a separate stream-api Route exists, attach this policy to it.
apiVersion: gateway.envoyproxy.io/v1alpha1kind: BackendTrafficPolicymetadata: name: stream-api-timeout namespace: defaultspec: targetRefs: - group: gateway.networking.k8s.io kind: HTTPRoute name: stream-api timeout: http: requestTimeout: 0s streamIdleTimeout: 30s maxStreamDuration: 600sIf stream-api still has a finite timeouts.request or backendRequest, that value takes precedence over the policy’s requestTimeout: 0s. This example assumes no built-in HTTPRoute timeout remains.
Thirty and 600 seconds are illustrative settings, not fixed recommendations. Choose values using normal data intervals, time to the first response, cancellation handling, and resource occupancy. If response headers have already been sent, a timeout may appear as a stream ending or reset rather than a new HTTP 504.
Operational guidance and limits
Section titled “Operational guidance and limits”- Separate ordinary and long-running APIs by Route. Check the affected scope before increasing a shared Gateway limit across the board.
- Decide whether HTTPRoute or policies own request timeouts. Maintaining them in both places can make shared policy changes ineffective.
- Inspect final Route dumps and request results, not just configuration values. Verify application cancellation and cleanup so unnecessary work does not continue after the timeout.
- The precedence described here is for v1.9.0.
ListenerSet, retry and fault-injection combinations, and dynamic overload limits are outside the scope.
References
Section titled “References”- Envoy Gateway HTTP timeouts
- BackendTrafficPolicy targets, precedence, and merging
- Gateway API HTTP timeouts
- Envoy timeout types
- Istio request timeouts
- AKS Istio add-on ingress
- v1.9.0 HTTPRoute timeout translation
- v1.9.0 final Route timeout selection
- PR #4860 separating policy and HTTPRoute timeouts
- Using egctl