Skip to main content

Retry

The Retry middleware reissues requests a given number of times to a backend server if that server does not reply.
As soon as the server answers, the middleware stops retrying, regardless of the response status. The retry is done to the TCP level. The Retry middleware has an optional configuration to enable an exponential backoff.


Configuration Example

Retry 4 times with exponential backoff
apiVersion: traefik.io/v1alpha1
kind: Middleware
metadata:
name: test-retry
spec:
retry:
attempts: 4
initialInterval: 100ms

Configuration Options

FieldDescriptionDefaultRequired
attemptsnumber of times the request should be retried.Yes
initialIntervalFirst wait time in the exponential backoff series.
The maximum interval is calculated as twice the initialInterval.
If unspecified, requests will be retried immediately.
Defined in seconds or as a valid duration format, see time.ParseDuration.
0No
statusDefines the range of HTTP status codes to retry on.
More information here.
[]No
disableRetryOnNetworkErrorDisables the retry when an error occurs while transmitting the request to the server.
More information here.
falseNo

disableRetryOnNetworkError and status

The disableRetryOnNetworkError option disables the retry when an error occurs while transmitting the request to the server, at the TCP layer. If you want to retry only for specific HTTP status codes, configure the status option with the relevant status codes to retry on.

If disableRetryOnNetworkError is set to true, you must define the status option. Otherwise, the middleware raises a configuration error.