n8n Error Handling: Retries, Error Output and Alerts
n8n error handling works in layers: use Retry On Fail for transient errors like 429 and 5xx, Continue (using error output) to route failed items to a fallback, and an Error Trigger workflow to send Slack or email alerts when a run fails.
- Retry On Fail only helps transient errors (429, 5xx, timeouts); 400, 401 and validation errors fail identically on every attempt.
- Max Tries includes the first attempt, so the default of 3 means one original call plus two retries.
- Continue (using regular output) passes failed items downstream with an error field, so check for it with an IF node or use the error output instead.
- The Error Trigger workflow fires only for failed production executions, never for manual test runs or for nodes set to Continue.
- Use a Stop And Error node to turn bad but technically successful results, such as an empty LLM reply, into a real failure that triggers your alert.
Which n8n error-handling tool fits which failure?
n8n gives you four separate tools, and each answers a different question. Retry asks whether trying again will work. Continue asks whether the run can proceed without this item. Error output asks where a failed item should go instead. The Error Trigger workflow asks who needs to know.
Pick by failure type, not by habit. Most production workflows combine two or three of these.
| Failure type | Example | Tool | Where to configure |
|---|---|---|---|
| Transient, likely to pass on retry | 429 rate limit, 502/503, network timeout | Retry On Fail | Node Settings tab |
| Tolerable, the run should go on | Optional enrichment lookup returns nothing | On Error: Continue (using regular output) | Node Settings tab |
| Needs a fallback, logging or a message | Primary LLM fails, use a cheaper model; log bad rows to a sheet | On Error: Continue (using error output) | Node Settings tab, then wire the second output |
| Needs a human to know | Run failed overnight, credentials expired | Error Trigger workflow | Workflow Settings, Error Workflow |
| Technically successful but wrong | Empty LLM text, 200 response with an error body | IF or Switch plus Stop And Error | In the workflow itself |
How do I set up Retry On Fail with backoff?
Open the node, choose the Settings tab and switch on Retry On Fail. Two fields appear: Max Tries (default 3) and Wait Between Tries (ms, default 1000). Max Tries counts the first attempt, so 3 means the original call plus two retries.
The wait is a fixed delay, not exponential backoff. For a 429 rate limit, a 1 second wait usually just hits the limit again, so raise it to several seconds. The UI has historically capped both fields (a handful of tries, a few seconds of wait), so for long rate-limit windows combine retries with batching or a Wait node.
Retries are useless for deterministic errors. A 400 bad request, 401 unauthorized or a validation failure returns the same result every time, and you only add delay. Fix the cause or route it to an error output instead.
{
"retryOnFail": true,
"maxTries": 4,
"waitBetweenTries": 5000
}What is the difference between Continue (regular output) and Continue (using error output)?
The On Error setting has three options: Stop Workflow (default), Continue (using regular output) and Continue (using error output). It replaced the older Continue On Fail toggle.
With regular output, a failed item flows down the normal path carrying an error field in its JSON. Later nodes treat it as ordinary data, so you may write blank rows, email empty templates or call an API with undefined values. If you use it, add an IF node right after that checks whether the error key exists.
With error output, the node gets a second output. Failed items go only to that branch, and the success output stays clean. Wire the error branch to a fallback API, a Google Sheets or database log, or a Slack message.
| Option | Failed items go to | Risk |
|---|---|---|
| Stop Workflow | Nowhere, the run fails | Whole run stops; Error Trigger fires |
| Continue (regular output) | Main output with an error field | Bad data processed downstream |
| Continue (using error output) | Separate error output | Unwired error branch silently drops failures |
IF condition (expression, boolean is true):
{{ $json.error !== undefined }}
true -> log / skip
false -> continue normal processingHow does per-item behaviour work, and why does a branch silently stop?
With several input items, each item is handled on its own. Only the failing items go to the error output, and the rest continue on the success output. Ten items with two failures give eight on success and two on error.
A branch silently stops when a node returns zero items, because downstream nodes get nothing to run on. A search that finds no rows, or a filter that removes everything, ends that path with no error. Turn on Always Output Data in the node Settings to emit one empty item so the flow continues, then check for it with an IF node.
Execute Once makes a node run only for the first input item. It suits things like a single notification after a loop. It is wrong for per-item API calls, because the remaining items are skipped and nothing flags it.
How do I build an Error Trigger workflow that sends alerts?
The Error Trigger lives in its own workflow, which one or many workflows can use as their error handler.
- Create a new workflow and name it something like Global Error Alerts. Add the Error Trigger node as the first node.
- Add a Slack, Email (SMTP), Telegram or Discord node after it and build the message from expressions (see below).
- Save the workflow. It does not need a schedule or a webhook, but it must be saved.
- Open each main workflow, then its Settings (the three-dot menu), and pick Global Error Alerts under Error Workflow. Save.
- Trigger a real failure in an active workflow to test it (see the gotchas below).
Workflow failed: {{ $json.workflow.name }}
Node: {{ $json.execution.lastNodeExecuted }}
Error: {{ $json.execution.error.message }}
Run: {{ $json.execution.url }}Why did my Error Trigger not fire, and how do I test it?
The Error Trigger only fires for automatic production executions of an active workflow, such as schedule, webhook production URL or app triggers. Clicking Execute Workflow in the editor never calls it, which is the most common reason people think it is broken.
It also does not fire for nodes set to Continue, because the execution itself did not fail. And it only fires for workflows that have the error workflow selected in their own Settings; there is no automatic global default.
To test, make a small active workflow with a Schedule or Webhook trigger and a Stop And Error node, assign the error workflow, activate it and call the production webhook URL. The error workflow's own manual run only shows sample data, so it checks formatting, not wiring.
Also remember the error workflow can fail too, for instance when a Slack token expires, and nothing alerts you. Keep it minimal, use a reliable channel, and consider a second channel such as email.
How do I validate results and handle AI workflows?
Many failures are not exceptions. An API can return 200 with an error body, and an LLM can return empty or malformed text. In the HTTP Request node, open Options and add Response, then enable Include Response Headers and Status and Never Error. Now a 404 or 500 becomes data, and an IF or Switch node can branch on {{ $json.statusCode }}. For plain failures you can leave the default, which errors on non-2xx.
Always set Options, Timeout (ms) on HTTP Request so a hung endpoint does not hold the run. For rate limits, use Options, Batching with Items per Batch and Batch Interval (ms) to space out calls instead of relying only on retries.
Use Stop And Error when validation fails. It fails the run with a custom message, which also triggers the error workflow. For example, after an LLM node, check {{ $json.output?.trim().length > 0 }} and send the false branch to Stop And Error with the message LLM returned empty response.
A solid AI pattern: set Retry On Fail on the primary LLM node (3 to 4 tries, 3000 to 5000 ms), set On Error to Continue (using error output), and connect that output to a second LLM node with a cheaper model. Merge both paths, parse the JSON in a Code node or an output parser, validate required keys with an IF node, and send failures to Stop And Error.
# Code node (Python): validate LLM JSON, flag bad items
import json
out = []
for item in _items:
raw = item["json"].get("text", "")
try:
data = json.loads(raw)
ok = "summary" in data
except Exception:
data, ok = {}, False
out.append({"json": {"valid": ok, **data}})
return out How do I debug failed runs and avoid common mistakes?
Open the Executions list and filter by status Failed. The failed node is highlighted, and the error message and input data are visible. You can retry the execution from the failed node, or copy it into the editor, pin the data on the node that failed, and iterate without hitting the API again. Retention is limited by execution data settings, so failures may vanish after pruning. On self-hosted instances, check variables such as EXECUTIONS_DATA_PRUNE and EXECUTIONS_DATA_MAX_AGE, and consider saving failed executions even if you skip successes.
Common mistakes:
Setting Continue on every node, which hides real failures and bypasses alerts. Reserve it for optional steps and always wire or log the error output.
Retrying non-idempotent actions, producing duplicate records or emails.
Retrying 400, 401 or validation errors, which wastes time and gets you nowhere.
Leaving an error output unconnected, which drops failed items silently.
Never testing the error workflow with a real production failure.
Common questions
Does n8n retry on fail with exponential backoff?
No. Retry On Fail uses a fixed Wait Between Tries value in milliseconds. If you need real backoff, build a loop with a Wait node and an expression that grows the wait with the attempt number.
Can one Error Trigger workflow serve many workflows?
Yes. Select the same workflow under Error Workflow in each main workflow's Settings. Use workflow.name and execution.url in the alert message so you can tell which workflow failed and open the exact run.
Why does my workflow keep running after a node errored?
The node is probably set to Continue, either on regular or error output. In that case the failed item moves on and the execution is marked successful. Check the node's On Error setting and look for an error field in the output.
Does the Stop And Error node trigger the error workflow?
Yes, if the run is an active production execution and the workflow has an error workflow selected. It fails the execution on purpose with your message, which then appears in the Error Trigger payload as execution.error.message.
How do I handle a 429 from an API in n8n?
Enable Retry On Fail with a longer wait, and reduce the request rate with HTTP Request Batching (items per batch plus a batch interval). If the provider sends a Retry-After header, n8n does not honour it automatically, so size your interval to match it.