🏠 Home / Hub

n8n 06 — Error Handling & Monitoring

Production workflows must handle failures gracefully. This lesson covers node-level error options, global error workflows, alerting, and safe testing practices.

1. Error Handling Options Per Node

Every node in n8n has an "On Error" setting accessible from the node's settings panel (gear icon or the Settings tab).

ModeBehaviourBest for
Stop WorkflowHalts execution immediately on errorCritical steps where failure must stop all processing
ContinueError is ignored, workflow continues with next itemBest-effort steps, optional enrichments
Continue With Error OutputError data passed to next node instead of normal outputWhen you want to log or alert on each individual failure
The default is "Stop Workflow". Change it per node based on how critical that step is to the overall automation.

2. Error Trigger Workflow (Global Error Catcher)

Create a separate workflow with an Error Trigger node as the first node. In any other workflow's Settings, set "Error Workflow" to this catcher workflow. It fires automatically when that workflow fails.

# Error Trigger data available in the catcher workflow:
$json.execution.id         # Failed execution ID
$json.execution.url        # Link to the failed execution
$json.workflow.id          # Workflow that failed
$json.workflow.name        # Workflow name
$json.error.message        # Error message
$json.error.stack          # Stack trace
$json.lastNodeExecuted     # Node name where it failed
# Catcher workflow structure:
Error Trigger
   └─► Set Node (format alert message)
         └─► Slack / Telegram / Email (send alert)

3. Try/Catch Pattern

Use "Continue With Error Output" + an IF node to build a try/catch style pattern inline:

# Step 1: HTTP Request node
On Error: Continue With Error Output

# Step 2: IF node after HTTP Request
Condition: {{ $json.error }} exists
  TRUE branch  → handle error (log, alert, fallback)
  FALSE branch → continue with successful response

# The error output item has this shape:
{
  "error": "Request failed with status 404",
  "statusCode": 404,
  "node": "Fetch User"
}
This pattern lets you handle different HTTP status codes differently — retry on 429 (rate limit), alert on 500, skip on 404.

4. Execution Monitoring

# Execution statuses:
success  → all nodes completed without error
error    → at least one node threw an unhandled error
running  → currently executing
waiting  → paused at a Wait node
canceled → manually stopped

5. Sending Alerts on Failure

Slack alert on failure

# In the Error Catcher workflow:
Error Trigger
   └─► Slack node (Send Message)
         Channel: #alerts
         Message:
         *Workflow Failed* :red_circle:
         Workflow: {{ $json.workflow.name }}
         Error: {{ $json.error.message }}
         Node: {{ $json.lastNodeExecuted }}
         View: {{ $json.execution.url }}

Telegram alert

# Telegram node
Chat ID: your-chat-id
Message:
❌ n8n Error
Workflow: {{ $json.workflow.name }}
Error: {{ $json.error.message }}
Time: {{ $now.toFormat('yyyy-MM-dd HH:mm') }}

6. Execution Log Cleanup

# Environment variables to control log retention:
EXECUTIONS_DATA_MAX_AGE=30        # Delete logs older than 30 days
EXECUTIONS_DATA_SAVE_ON_ERROR=all # Save logs: all/none
EXECUTIONS_DATA_SAVE_ON_SUCCESS=none # Don't save successful runs
EXECUTIONS_DATA_SAVE_ON_PROGRESS=false

# Why limit logs?
# - Execution data can grow large, especially with binary files
# - Postgres performance degrades with millions of rows
# - Set to save errors only in high-volume automations

7. Using the Wait Node

The Wait node pauses a workflow execution for a specified time or until a webhook resumes it.

# Time-based wait:
Resume: After Time Interval
Wait Amount: 30
Wait Unit: Minutes
# Execution is paused — does not consume resources

# Webhook-based resume:
Resume: On Webhook Call
# n8n gives you a unique "resume URL"
# Send a POST to that URL to continue the workflow

# Use case: send approval email, wait for user to click "Approve"
Webhook Trigger
   └─► Send Email with approval link (contains resume URL)
         └─► Wait (Resume: Webhook)
               └─► IF approved → process / reject → log
Waiting workflows count against your concurrent execution limit on n8n cloud. For long waits (hours/days), this can matter at scale.

8. Testing Workflows Safely

Build the entire workflow in test mode with pinned data before activating. This way you never spam a real API or send live emails while developing.

📌 Study Checklist