Which failed n8n executions are safe to retry?
Retrying a failed n8n execution repeats every non-idempotent step before the failure. A practical test for safe retries, and rules for automating them.
n8n makes retrying easy: open a failed execution and click retry, or call the API. That ease is exactly the risk. A retry re-runs the workflow, and depending on how you retry it, steps that already succeeded before the failure may run again.
If one of those steps sent an email, charged a card or created a CRM record, the retry does it again.
The one-question test
Before retrying any failed execution, ask:
Did any node that ran before the failure cause an external side effect that isn't idempotent?
A side effect is idempotent when doing it twice has the same result as doing it once:
- Idempotent: upserting a row by a stable id; a PUT that sets the same fields to the same values; a payment API call that carries an
Idempotency-Key; a step guarded by a "have we done this event?" claim in a database. - Not idempotent: sending an email or message; creating a record with a POST; appending a row; incrementing a counter; charging without an idempotency key.
If the answer is "no", the retry is safe. If it's "yes", fix the workflow first. Usually that means putting an idempotency guard in front of the side effect, or replacing a create with an upsert.
Not every error is worth retrying
Even a perfectly idempotent workflow shouldn't be retried for every error. The error class tells you whether a retry can help:
| Retry automatically | Don't retry automatically |
|---|---|
| Rate limits (429) | Authentication (401/403, expired tokens) |
| Timeouts | Validation errors (4xx, bad data) |
| Network errors (reset, refused, DNS) | Code errors ("cannot read properties of undefined") |
| Upstream 5xx | Anything you don't recognise |
Retrying an auth or validation failure just repeats it. Worse, it can repeat the side effects that ran before the failing node.
Rules for automating retries
If you want failed executions retried without a human, put limits on it:
- Allowlist workflows. Nothing is retried unless someone has explicitly marked that workflow safe after applying the test above. Opt-in, never opt-out.
- Transient errors only. Use the left column of the table.
- Back off. Wait at least 15 minutes before the first retry and longer before the second. Rate limits and outages need time to clear.
- Cap attempts. Two automatic attempts per failed execution is plenty. After that, a human looks.
- Cap the blast radius. Limit how many retries can happen per run (say, ten per hour), so a systemic problem doesn't become a retry storm.
- Record everything. Keep a ledger of which execution was retried, when, and with what outcome. Never automatically retry an execution that was already retried successfully.
- Start in dry run. For the first days, report what would be retried and change nothing. Read those reports. It's the cheapest way to find a workflow you thought was safe and isn't.
Using the API
Recent n8n versions expose POST /api/v1/executions/{id}/retry in the Public API. Combined with the executions list (status=error) and your error workflow's records, that's enough to build an automated recovery loop. Check your version's API reference first, and test against a non-production instance.
Pair retries with an idempotency gate
The most reliable setup doesn't rely on remembering which workflows are safe. It makes the dangerous steps safe. A gate before each side effect claims the event id in a database. A retry, or a duplicate webhook delivery, then finds the claim and skips the side effect. We cover the pattern in why your n8n webhook runs twice.
The Safe Recovery workflow in the Reliable Automation Kit implements these seven rules, dry run by default, and reads error classes recorded by the kit's error router.
Related
n8n 2.20: publish your sub-workflows and error workflow first
In n8n 2.20.8 a published workflow could not run an unpublished sub-workflow or error workflow. What we saw in testing, and an install order that avoids it.
Why your n8n webhook runs twice (and the one-statement fix)
Webhook providers deliver at least once. Why n8n processes the same event twice, why check-then-insert fails, and a race-safe Postgres fix.