HAProxy Enterprise Documentation 2.0r1

Retry a Failed HTTP Request

To retry an HTTP request when the server returns an HTTP error:

  1. In a defaults or backend section of your load balancer configuration, set the retries directive to the number of times to retry a failed HTTP request.

    Attempt to connect to the server 5 times before giving up and returning the HTTP error.

    backend webservers
       mode http
       retries 5
  2. Add the retry-on directive to define specific types of HTTP errors that should trigger a retry. Options include:

    • 404

    • 408

    • 425

    • 500

    • 501

    • 502

    • 503

    • 504

    • all-retryable-errors

    Retry when the request fails due to failure 503 or 504.

       retry-on 503 504
  3. Optional: Add to the retry-on directive specific types of TCP connection problems that should trigger a retry, in addition to HTTP conditions. Options include:

    • conn-failure

    • empty-response

    • response-timeout

    • 0rtt-rejected

    • all-retryable-errors

    Retry the connection if the connection could not be established or was closed while sending the request.

       retry-on conn-failure empty-response 500

Next up

Circuit Breakers