# Automatic Retrying

## Introduction

Locoia has an **automatic retry logic for failed flows** to handle third party timeouts, downtimes, rate limits, etc.. This makes it very convenient that if something goes wrong along the way your data and any temporarily generated data is stored and can be reused in order to continue exactly where the Flow Run was unintentionally stopped.

Automatic retrying is turned on by default, but can be turned off on a per Flow basis in the Flow's settings.

![](https://291121471-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-McrRFZHYH27bqKzOVDd%2Fuploads%2F0lnT90WsbanlDkmVw0Kb%2FRetry%20Flow.png?alt=media\&token=32170ac3-bc3c-4e2f-a4f8-907e664fd6fe)

## Possible reasons for failure

* Flow is setup or built incorrectly
* Flow is built to process data in a certain way, but there may be data inconsistencies from time to time, as usual in data handling.
* Systems or APIs that flows interact with may be down or temporarily out of service.
* Systems or APIs may have rate limits allowing only a certain number of API calls per time unit, e.g. 100 per minute is often used.

## How flow failure is handled - smart retries

There are three different groups of errors, which have different retry logics:

| Groups                                                                                                                                      | Retryable, with a long delay                                                                                                                                                                                                                               | Retryable, with a short delay                                                                                                                                                                            | Non-retryable                                                                                                                                                                                   |
| ------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Applies to all** [**Connectors**](https://docs.locoia.com/connectors/connectors) **and the following Helpers**                            | [Rest Helper](https://docs.locoia.com/connectors/helpers/rest-helper)                                                                                                                                                                                      | <p><a href="../../connectors/helpers/rest-helper">Rest Helper</a><br><a href="../../connectors/helpers/ftp-client">FTP Helper</a><br><a href="../../connectors/helpers/sql-helper">SQL Connector</a></p> | [All Helpers](https://docs.locoia.com/connectors/helpers)                                                                                                                                       |
| <p><strong>Applicable errors</strong><br><strong>(Checks from left to right, if any of the cases are applicable \['OR' check])</strong></p> | <ul><li>HTTP status codes <code>429</code>, <code>503</code></li><li><code>Retry-After</code> or <code>X-RateLimit-Reset</code> header is specified (except for <code>2xx</code> status codes)</li></ul>                                                   | <ul><li>HTTP status is <code>5xx</code> (except for <code>503</code>)</li><li>DNS resolution failed</li><li>Network connection was abruptly closed</li><li>Generic network error happened</li></ul>      | <ul><li>HTTP status is <code>4xx</code> (except for <code>429</code>)</li><li>User input contains Jinja syntax errors</li><li>+ All errors that didn’t fall into the first two groups</li></ul> |
| **Retrying behavior**                                                                                                                       | <p>Retry once based on the <code>Retry-After</code> or <code>X-RateLimit-Reset</code> header or, if not set, after 3 minutes.<br>If the <code>Retry-After</code> header specifies a value higher than 10 minutes, retrying will not take place at all.</p> | Retry after 1 second, regardless of Flow status and [custom error handling](https://docs.locoia.com/automation/flow-builder/custom-error-handling) settings.                                             | No retrying                                                                                                                                                                                     |
| **Visibility in Flow Debugger while retrying**                                                                                              | Flow Run and Flow Run Step have status `retrying`                                                                                                                                                                                                          | Flow Run and Flow Run Step have status `running`                                                                                                                                                         | N/A                                                                                                                                                                                             |

For all retry groups an [error email](https://docs.locoia.com/flow-builder/flow-run-data-retention-and-logging#error-notifications) will be sent once the Flow Run's status changed to `error` (i.e. once retrying has taken place).

[Error Handling Flows](https://docs.locoia.com/automation/flow-builder/error-handling-flows) will be triggered for each error Flow Run Step, even if it is being retried successfully.

{% hint style="warning" %}
When the [Flow's data retention](https://docs.locoia.com/automation/flow-builder/flow-run-data-retention-and-logging) is set to 0 and an error occurs in one of the steps that falls into the first group, this step's contents will be temporarily stored and displayed in the Flow Debugger in order to make retrying possible.

In case you don't want this to happen, automatic retrying has to be disabled for the Flow
{% endhint %}
