Lompat ke konten

Pelajaran 16 ยท Errors and Debugging

Error Handling in n8n

Make n8n workflows resilient with Retry On Fail, the On Error setting and error outputs, error workflows with the Error Trigger and the Stop And Error node.

APIs go down, tokens expire and someone types a date as "next Tuesday". Failures will happen. A good workflow decides in advance what to do about them, so you hear about problems quickly and no data disappears.

Three layers

Layers of defense

Node retry Brief hiccups
Node error path Handle known failures
Error workflow Alert on failed runs
1 / 2

Retry On Fail

In a node's settings, Retry On Fail runs it again after a failure. Use it for temporary problems, such as a brief network error. The number of tries and wait are limited (the docs list up to five tries and a wait of at most 5,000 ms). It will not fix a wrong password or invalid data. It does not read a server's Retry-After header automatically, so longer waits need your own design. Be careful with actions that create things, because a retry can duplicate them.

The On Error setting

Each node can say what happens when it fails:

Option Behavior
Stop Workflow The execution fails (the usual default)
Continue The workflow carries on
Continue (using error output) Failed items go to a separate error output

The error output is usually the best way to handle expected problems: send good items onward and route bad ones to a "needs attention" list. With plain Continue, make sure you can still tell what failed, or errors may pass silently.

Python Stand-in: split successes and failures

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Keeping the original input beside the error makes it possible to fix and replay it later.

Error workflows

For failures you did not plan for, create a separate error workflow that starts with the Error Trigger node. Then, in each workflow you want to watch, choose it as the Error workflow in the workflow settings. One error workflow can serve many others. It can post to a chat channel, open a ticket or send an email.

The Error Trigger receives information about the execution (such as its ID, URL, error message, last node and mode) and the workflow (ID and name). An illustrative alert message:

TEXT
Workflow {{ $json.workflow.name }} failed at node
{{ $json.execution.lastNodeExecuted }}:
{{ $json.execution.error.message }}
Details: {{ $json.execution.url }}

If the failure happens in the trigger itself, some execution fields may be missing, so use fallbacks. Also note that error workflows run for automatic executions: you cannot test them by running the failing workflow manually. The Error Trigger documentation (December 2026) says you must publish the workflow that contains the Error Trigger. It also says such a workflow uses itself as its error workflow by default.

JS Stand-in: format a safe alert

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Shorten messages and avoid copying whole data records into alerts, because chat channels may be seen by many people.

Fail on purpose

Sometimes the data is technically fine but wrong for your business, for example a negative invoice total. Add Stop And Error after your check, with a clear message. This makes the execution fail visibly and triggers the error workflow.

What to alert on

Too many alerts get ignored. Alert on things someone must act on. For minor issues, collect them and send a daily summary.

Common mistakes

  • Setting Continue everywhere so failures disappear.
  • Relying on an error workflow that nobody monitors.
  • Retrying create or payment requests without protection against duplicates.

Decide what should happen at each step

Walk through your workflow and ask three questions at each step that talks to another system. Could this fail temporarily? If yes, consider a retry. Could some records be bad while others are fine? If yes, use the error output and keep the bad records for review. Would continuing after failure be dangerous? If yes, stop the workflow. For example, if fetching the list of blocked recipients fails, do not send the emails anyway.

Think about the half-finished case. Suppose you created a record in system A and then system B failed. Running the workflow again must not create a second record in A. Either make step A safe to repeat or record that it succeeded. Some processes need a compensating action, such as cancelling a reservation when payment fails.

Finally, give every alert an owner and a short runbook: what the failure means, how to check it, how to replay the affected items and whom to contact. An alert that nobody knows how to act on is only noise.

Practice

Design error handling for a workflow that reads invoices, creates them in an accounting system and emails the customer. For each of the three steps, choose retry or not, stop or continue, and where failed records go. Pay special attention to the email step: what happens if the invoice was created but the email failed, and you run the workflow again? Write the alert message you would want to receive at night, with the information needed to act and no more personal data than necessary. Then check that each failure path ends somewhere a person will actually look.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which problem is Retry On Fail best for?

    Retrying helps only if the cause may go away by itself.
  2. 2. What does Continue (using error output) do?

    You can route failed items to your own handling.
  3. 3. Which node starts an error workflow?

    An error workflow begins with the Error Trigger.
  4. 4. How do you make a run fail for a bad business value?

    Stop And Error forces a visible failure.

Summary

  • Retry temporary failures, but protect actions that create things.
  • Use error outputs to handle expected problems per item.
  • Connect an error workflow with the Error Trigger for alerts.
  • Fail on purpose when business rules are broken.

Next: Debugging and Reliable Workflows

Progres Anda disimpan di browser ini. Tidak perlu akun.