All Products
Search
Document Center

API Gateway:Configure a retry policy

Last Updated:Dec 17, 2025

Cloud-native API Gateway allows you to configure route-level retry policies. This enables automatic retries for failed requests. In a retry policy, you can specify retry conditions, such as failed connections, unavailable backend services, or responses with specific HTTP status codes.

Retry conditions

When a backend service returns a 5xx error, Cloud-native API Gateway automatically retries the failed request based on the specified maximum number of retries.

image
  • HTTP Protocol retry conditions:

    • 5xx: If the backend service returns any 5xx response, or if a connection is disconnected, reset, or times out during read operations, Cloud-native API Gateway attempts to retry the failed request.

      Note

      5xx includes the connect-failure and refused-stream conditions.

    • reset: If a connection is disconnected, reset, or times out during read operations, Cloud-native API Gateway attempts to retry the failed request.

    • connect-failure: If a request fails because a connection is disconnected, Cloud-native API Gateway attempts to retry the failed request.

    • refused-stream: If the backend service resets a stream with the REFUSED_STREAM error code, Cloud-native API Gateway attempts to retry the failed request.

    • retriable-status-codes: If the HTTP status code in the response from the backend service matches the retry status code that you specify, Cloud-native API Gateway attempts to retry the request.

      Note

      You can use retry status codes only if you specify retriable-status-codes in the retry conditions.

  • GRPC Protocol retry conditions:

    • cancelled: If the gRPC status code in the response header from the backend gRPC service is cancelled, Cloud-native API Gateway attempts to retry the request.

    • deadline-exceeded: If the gRPC status code in the response header from the backend gRPC service is deadline-exceeded, Cloud-native API Gateway attempts to retry the request.

    • internal: If the gRPC status code in the response header from the backend gRPC service is internal, Cloud-native API Gateway attempts to retry the request.

    • resource-exhausted: If the gRPC status code in the response header from the backend gRPC service is resource-exhausted, Cloud-native API Gateway attempts to retry the request.

    • unavailable: If the gRPC status code in the response header from the backend gRPC service is unavailable, Cloud-native API Gateway attempts to retry the request.

Configure a retry policy

  1. Cloud-native API Gateway provides two ways to configure retry policies: outside an instance and inside an instance:

    API outside an instance

    1. Log on to the Cloud-native API Gateway console. In the left-side navigation pane, select API, and select a region in the top menu bar.

    2. Click the target API. You can select the instance for which you want to configure a retry policy from the drop-down list, or select All Instances.image

    3. Select the target route from the Route List.

    API inside an instance

    1. Log on to the Cloud-native API Gateway console. In the left-side navigation pane, select Instance, and select a region in the top menu bar.

    2. On the Instance page, click the ID of the target gateway instance. In the left-side navigation pane, select API, and click the target API.

    3. On the Routes tab, select the target route.

  2. Click the Policy Configuration tab, and click Enable Policy/Plug-in in the Inbound Processing section.

  3. Click the Retry card. In the Add Policy: Retry panel, configure the parameters and click OK.

    Note

    After the retry policy is created and enabled, you can verify whether the retry policy is effective based on your business requirements.

    Parameter

    Description

    Enable

    Specifies whether to enable the retry policy.

    • If you turn on the switch, the retry policy takes effect.

    • If you turn off the switch, the retry policy does not take effect.

    Note

    If you disable retries, the gateway uses the default retry configuration. The default maximum number of retries is 2, and the default retry conditions are connect-failure, refused-stream, unavailable, cancelled, and retriable-status-codes.

    Retry Times

    The maximum number of retries for a failed request. You can set this parameter to an integer ranging from 0 to 10. We recommend that you set this parameter to 0, 1, or 2.

    Note

    If this parameter is set to 0, failed requests are not retried.

    Retry Interval (s)

    The condition that triggers retries. You can select one or more conditions. For more information, see Retry conditions.

    Retry Status Code

    The HTTP status code that triggers retries. You can specify one or more HTTP status codes.

    Note

    You can configure Retry Status Code only if you specify retriable-status-codes in Retry Condition.