n8n Error Handling: A Complete Guide to Reliable Workflows
By Abhishek Patoliya · 2026-08-12
A workflow that runs perfectly in testing and then fails silently in production isn't a rare edge case. It's the default outcome for any automation that doesn't plan for failure. An upstream API goes down for ten minutes, a webhook sends a field with the wrong type, a rate limit kicks in during a busy hour. Without deliberate error handling, n8n either stops the run and nobody notices, or worse, continues with bad data and nobody notices that either. n8n error handling is the set of patterns that turn those failures from invisible outages into logged, recoverable, or at least alerted events.
Why This Matters More Than It Looks Like It Should
A workflow with no error handling has exactly one behavior when something goes wrong: it stops, and the failure sits in n8n's execution log until someone happens to check it. For a workflow that runs once a day, that might mean a full day's delay before anyone notices a report never went out. For a workflow handling live customer support tickets or lead routing, it means requests silently drop on the floor during the exact window something upstream is unstable. The fix isn't complicated, but it has to be designed in from the start — bolting on error handling after a production incident is a much worse position than building it in from the first version.
The Building Blocks
The On Error setting (formerly Continue On Fail)
Every node has an On Error setting in its Settings tab, with three options:
- Stop Workflow (the default): the run stops at that node and fails. If the workflow has an error workflow, it runs.
- Continue: the workflow carries on. The failed node outputs an item containing an
error object on its normal output, so the next node runs whether or not the call worked. Check for that field with an IF node before using the result.
- Continue (using error output): the node gets a second output. Failed items leave on it with their original data plus an
error object, and only successful items go out of the normal output.
Older guides call this setting Continue On Fail. In current n8n, Continue (using error output) is usually the better choice: failures can't slip into the success path by mistake, and the failed item still carries the data you need for a fallback or a log entry. Use it when a failure at one step shouldn't end the whole run. A non-critical enrichment API failing shouldn't stop a lead from being saved to the CRM.
Retry On Fail
Also in a node's Settings tab, Retry On Fail re-runs a failed node before treating it as an error. It has two values, Max Tries and Wait Between Tries (ms), and n8n limits both: at most 5 tries, and at most 5,000 ms between them. Ask for more and n8n uses the maximum. The wait is the same every time; it doesn't back off.
That suits brief failures, such as a dropped connection or a momentary 503. It doesn't suit an API whose rate limits and 429 errors reset after a minute: five tries five seconds apart are over in about 20 seconds. For longer waits, n8n's own rate-limit guide recommends batching or a Loop Over Items and Wait loop. And retrying does nothing for failures that will happen the same way every time, such as an invalid credential or a malformed request.
One more caution: a retry repeats the whole node. If the first attempt reached the other system and only the response was lost, the retry can send the email or create the record a second time. Retries can duplicate actions unless the request carries an idempotency key.
Error workflows
An error workflow is a separate workflow that starts with an Error Trigger node. In the workflow you want to protect, open its settings and choose the error workflow. n8n then runs it whenever an execution of that workflow fails outright, meaning a node with On Error set to Stop Workflow failed. One error workflow can serve any number of workflows, which makes it the natural place for logging and alerts.
Publish the error workflow. In current n8n (tested on version 2.47.4), an error workflow that has never been published doesn't run: n8n logs that it "is not active and cannot be executed" and the failure goes unrecorded. n8n runs the published version, so publish again after you change it.
The Error Trigger receives the details of the failure. For a failed run they include execution.id, execution.url, execution.error.message, execution.lastNodeExecuted, execution.mode, workflow.id and workflow.name. execution.retryOf is only present when the failed run was itself a retry, and execution.id and execution.url only when the execution was saved. When a trigger node fails, for example a workflow that can't be activated, the details arrive in a trigger object instead, with less information about the execution.
Stop And Error
Sometimes nothing technically failed, but the result is still wrong: an AI step returned an empty answer, or a record is missing a field you depend on. Put a Stop And Error node on that branch with your own message. The run fails on purpose, and the error workflow receives your message in execution.error.message, the same as any other failure.
A Practical Pattern: Layered Error Handling
The most reliable workflows don't rely on just one of these mechanisms — they layer them:
- Wrap risky nodes individually. Any node calling an external API, writing to a database, or calling an LLM gets On Error set to Continue (using error output) and, where the failure is likely to be brief, Retry On Fail.
- Branch on the outcome. The node's normal output continues as usual. Its error output goes to a fallback: a default value, a simpler retry with different parameters, or straight to logging.
- Log every failure, caught or not. Whether a failure was caught inline or triggered the Error Workflow, write it somewhere queryable: which workflow, which node, the input that caused it, the error message, and a timestamp.
- Alert only on what needs a human. A retry that eventually succeeded doesn't need to page anyone. A failure that exhausted its retries, or one with no defined fallback, does.
- Assign a shared Error Workflow across your important workflows. One central logging-and-alerting workflow, reused everywhere, is easier to maintain than duplicating the same error-handling logic inside every individual workflow.
The Part That's Easy to Miss: AI Steps Fail Differently
The On Error setting and Retry On Fail both assume the node threw a visible error: an API returned a 500, or a request timed out. An LLM or AI Agent node can fail in a way that throws nothing at all: it returns a response with no error, but the content is empty, malformed, doesn't match the JSON schema you expected, or is simply wrong. None of the mechanisms above catch that on their own.
The fix is an explicit check immediately after any model call: validate the model's output against a schema, with required fields present, correct types and nothing empty. When the check fails, either route the item to a fallback (see how to fall back gracefully when an LLM call fails) or send it to a Stop And Error node so the error workflow logs it. Skipping this step is the most common reason AI-powered n8n workflows look reliable in testing, then quietly produce bad output in production without a single error appearing in the execution log.
Choosing What to Log
n8n's own execution history isn't built for long-term debugging: execution history is pruned over time, and it's not easily searchable across many runs. For anything you actually need to review later, log to a destination outside n8n: a Postgres table, an Airtable base, or a Google Sheet all work. At minimum, capture:
- Timestamp and workflow name
- The specific node that failed (or the validation check that caught a bad AI output)
- The input data that triggered the failure
- The error message or validation reason
- Whether it was auto-recovered (retry succeeded, fallback used) or needs manual follow-up
That last field matters for keeping your logs useful rather than just long. It's what lets you filter straight to the failures that actually need attention.
Tracking Failures and Retries at Scale
Once several workflows share one error workflow, the n8n execution list stops being a practical way to see what's failing. Write each failure to a table instead. Here is a minimal schema to log failures to a Postgres table:
create table n8n_errors (
id bigint generated always as identity primary key,
occurred_at timestamptz not null default now(),
workflow_id text,
workflow_name text,
execution_id text,
execution_url text,
failed_node text,
error_message text,
mode text,
retry_of text,
payload jsonb not null
);
In the error workflow, put this Code node (Run Once for Each Item) between the Error Trigger and a Postgres node. It handles both shapes the Error Trigger sends:
// Code node, Run Once for Each Item: turn the Error Trigger's output into one log row.
// Workflow errors carry an execution{} object; errors in a trigger node carry trigger{} instead.
const e = $json;
const fromTrigger = !!e.trigger;
const err = fromTrigger ? e.trigger.error ?? {} : e.execution?.error ?? {};
return { json: {
workflow_id: e.workflow?.id ?? null,
workflow_name: e.workflow?.name ?? null,
execution_id: e.execution?.id ?? null, // missing if the execution wasn't saved
execution_url: e.execution?.url ?? null,
failed_node: fromTrigger ? (err.node?.name ?? null) : (e.execution?.lastNodeExecuted ?? null),
error_message: err.message ?? 'unknown error',
mode: fromTrigger ? 'trigger' : (e.execution?.mode ?? null),
retry_of: e.execution?.retryOf ?? null, // only set when the failed run was itself a retry
payload: JSON.stringify(e),
} };
Then insert the row with the Postgres node's Execute Query operation:
insert into n8n_errors (workflow_id, workflow_name, execution_id, execution_url, failed_node, error_message, mode, retry_of, payload)
values ($1, $2, $3, $4, $5, $6, $7, $8, $9::jsonb)
with Query Parameters set to {{ [ $json.workflow_id, $json.workflow_name, $json.execution_id, $json.execution_url, $json.failed_node, $json.error_message, $json.mode, $json.retry_of, $json.payload ] }}.
Two queries then answer most questions. Which workflows failed most this week:
select workflow_name, count(*) from n8n_errors
where occurred_at > now() - interval '7 days'
group by 1 order by 2 desc;
And which failures came from a run someone had already retried: select * from n8n_errors where retry_of is not null;. After the Postgres node, send the alert to Slack only for the failures that need a person.
Avoiding Alert Fatigue
It's tempting to wire every Error Workflow straight to a Slack channel, but a channel that pings for every transient retry quickly gets muted, which defeats the purpose. Reserve real-time alerts for failures that exhausted retries, hit a fallback with no good default, or represent something that will keep failing until a person intervenes. Everything else — a retry that eventually succeeded, a validation catch that safely fell back to a default — belongs in the log, checked periodically, not in an interrupt-driven alert.
For more on this, see how to avoid alert fatigue when something fails every few minutes, and how a circuit breaker can stop calling a failing service instead of failing on every run.
Testing Failure Paths on Purpose
Error handling that's never been tested against a real failure usually has a gap you won't find until production hits it. Before trusting a workflow with unattended runs, break it deliberately: point an HTTP Request node at an invalid URL, feed it malformed input or use a revoked credential, and confirm the fallback and logging behave the way you designed, not just that the happy path works.
One trap: the error workflow doesn't run when you execute a workflow manually from the editor. n8n skips error workflows for manual executions. So test the inline handling (error outputs and fallbacks) in the editor, then test the error workflow by letting the broken workflow fail from its real trigger: a schedule, a webhook call or a form submission. Manual and production runs differ in other ways too, and a workflow that works manually but fails on trigger covers the common causes. For a broader checklist, see how to test your failure paths before go-live.
Getting Started
If an existing workflow has no error handling at all, start with the single node most likely to fail, usually an external API call or an LLM step. Set its On Error to Continue (using error output) and add a validation branch there first. Add a shared Error Workflow next, so anything you haven't specifically handled at least gets logged instead of disappearing. Layer in Retry On Fail and tighter validation as you learn which failures in that specific workflow are actually transient versus which ones need a real fallback.
Written by Abhishek Patoliya, Senior n8n Developer & Automation Architect, Surat, India. Verified n8n Creator.