> ## Documentation Index
> Fetch the complete documentation index at: https://docs.alumio.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Retry requests on failure

> Retry a request when the response code matches the supplied failure range.

export const FormField = ({property, label, required = false, diType, uiPatterns, children}) => {
  const patterns = Array.isArray(uiPatterns) ? uiPatterns : uiPatterns ? [uiPatterns] : [];
  return <div style={{
    margin: '1.5rem 0'
  }}>
      <div style={{
    display: 'flex',
    alignItems: 'baseline',
    flexWrap: 'wrap',
    gap: '0.5rem',
    marginBottom: '0.25rem'
  }}>
        <strong>{label}</strong>
        <span style={{
    fontSize: '0.7rem',
    fontWeight: 600,
    textTransform: 'uppercase',
    letterSpacing: '0.04em',
    color: required ? '#6241f5' : '#6b7280'
  }}>
          {required ? 'Required' : 'Optional'}
        </span>
      </div>

      <div>{children}</div>

      {diType || patterns.length > 0 ? <p style={{
    fontSize: '0.85rem',
    color: '#6b7280',
    marginBottom: 0
  }}>
          {diType ? <>
              See the <a href={`/references/${diType}`}>{diType}</a> reference.{' '}
            </> : null}
          {patterns.length > 0 ? <>
              Accepts a <a href={`/documentation/placeholders-and-patterns/patterns#${patterns[0]}`}>pattern</a>.
            </> : null}
        </p> : null}
    </div>;
};

Retry a request when the response code matches the supplied failure range. Add this to a connection so that a request that fails for a temporary reason, such as the other system being briefly overloaded or unavailable, is automatically tried again instead of failing straight away. You decide how many extra attempts to make, how long to wait between them, and which response codes count as a failure worth retrying. By default it makes one extra attempt, waits one second in between, and retries on server error codes (500 up to but not including 600).

This documentation describes: [Schema](/schemas/http-client-plugin-configurator/retry)

## Fields

<FormField property="retries" label="Number of retries">
  How many extra attempts to make after the first request fails. Defaults to 1, so the request is tried once more. Set it higher to keep retrying a few times before giving up.
</FormField>

<FormField property="sleep" label="Number of seconds to wait until retry">
  How long to wait between attempts, in seconds. Defaults to 1. Increasing this gives a struggling system more time to recover before the next attempt.
</FormField>

<FormField property="ranges" label="Retry a request when the HTTP response code is within one or more ranges">
  The response codes that count as a failure worth retrying. Each range has a From and a To value: a response is retried when its code is equal to or higher than From and lower than To. You can add more than one range to cover different groups of codes. Defaults to a single range from 500 to 600, which covers the standard server error codes.
</FormField>

### Within each range

<FormField property="ranges[].from" label="From">
  The lowest response code in the range. A response is retried when its code is equal to or higher than this. Defaults to 500.
</FormField>

<FormField property="ranges[].to" label="To">
  The upper limit of the range. A response is retried only when its code is lower than this, so the To value itself is not included. Defaults to 600.
</FormField>

## Sample data

This plugin does not change the request or the response. It decides whether to send the same request again when it fails, so there is no before/after to show.

For example, the configuration below makes up to three extra attempts, waits two seconds between each, and retries on both server errors (500 to 600) and the "too many requests" code (429):

| Field                                 | Value                       |
| ------------------------------------- | --------------------------- |
| Number of retries                     | `3`                         |
| Number of seconds to wait until retry | `2`                         |
| Ranges                                | `429`–`430` and `500`–`600` |

```json Configuration theme={null}
{
  "prototype": "retry",
  "parameters": {
    "retries": 3,
    "sleep": 2,
    "ranges": [
      { "from": 429, "to": 430 },
      { "from": 500, "to": 600 }
    ]
  }
}
```
