Overview
In this lesson, you'll learn how to master error handling in n8n to build robust, reliable workflows that continue running smoothly even when errors occur. We'll explore practical techniques to handle API failures, log errors, retry operations, and notify your team, ensuring your automation processes don't break unexpectedly.
What is Error Handling in n8n?
Error handling is a critical concept in workflow automation that ensures your workflows keep running even if some steps fail. Instead of letting the entire workflow stop when an error occurs, error handling lets you:
- Retry failed operations (e.g., API calls)
- Log errors for later review
- Send notifications when issues arise
- Skip problematic items and continue processing others
This makes your automation more resilient and reliable, especially when dealing with external services that may be temporarily unavailable or return unexpected data.
Why is Error Handling Important?
- API downtime or temporary failures: Retry calls to recover from transient issues.
- Partial data failures: Continue processing other records even if one fails.
- Logging and notifications: Capture error details for debugging and alert your team.
- Prevent complete workflow stoppage: Ensure the rest of your automation runs without interruption.
For more on handling complex error scenarios, check out the Google Forms Webhook in n8n lesson, which covers advanced error workflows.
Setting Up Error Handling in n8n: A Step-by-Step Guide
Let's apply error handling to a workflow that processes email attachments and uploads images to a Notion taskboard. The workflow encounters an error when trying to upload a PDF as an image, causing the workflow to stop in the previous lesson. Here, you’ll learn how to prevent such failures from halting the entire workflow.
1. Open Your Workflow and Identify the Error-Prone Node
- Open your n8n editor and load your workflow (for example, the one processing email attachments and uploading to Notion).
- Identify the node that fails (in this case, the Notion node that expects images but receives a PDF).
2. Enable Retry on Fail for Temporary Errors
- Click on the error-prone node (Notion node).
- Go to Settings (gear icon).
- Enable Retry On Fail.
- Set Maximum Retries (e.g., 3) and Retry Interval (e.g., 1 second).
This will make the node retry up to three times if it encounters an error, useful for temporary API issues.
Settings > Retry On Fail: Enabled
Maximum Retries: 3
Retry Interval: 1 second
3. Configure Error Handling Behavior
By default, when a node fails, n8n stops the workflow. You can change this behavior:
- In the node’s Settings, find the On Error option.
- Change the action from Stop Workflow to either:
- Continue (pass error message as item in regular output)
- Continue using error output (pass items to an extra error output)
Option 1: Continue and Pass Error as Regular Output
This option allows the workflow to continue, and the error message is passed as part of the regular output. You can then filter or handle errors downstream.
Option 2: Continue Using Error Output (Recommended)
This creates two outputs from the node:
- Success output: Items processed successfully.
- Error output: Items that failed, including error details.
This approach is cleaner and easier to manage. For more details, refer to the n8n Merge node documentation which explains error output handling in depth.
4. Handle Errors Using the Extra Error Output
Once you enable Continue using error output, the node will have two outputs.
- Connect the success output to the next node in your workflow (e.g., continue uploading other attachments).
- Connect the error output to an Email node or a Logging node to notify your team or save error details.
Example: Sending an Email Notification on Error
- Add an Email node (e.g., AWS SES or SMTP).
- Connect it to the error output of your node.
- Use expressions to include error details in the email body:
Subject: Error Occurred in Workflow
Body: Error occurred during processing of item with URL {{$json["url"]}}. Error message: {{$json["error"]["message"]}}
From Email: noreply@example.com
To Email: devteam@example.com
5. Optional: Use an IF Node for Conditional Error Handling
If you choose Continue (pass error message as item in regular output), errors come mixed with normal output. Use an IF node to check if an error exists:
- Add an
IFnode. - Use the following expression to check for errors:
{{ $json.error !== undefined }}
- Connect the
truebranch to an error handling node (email, logging). - Connect the
falsebranch to continue processing.
This technique is useful for workflows like the Gmail Attachments to Google Drive automation, where debugging and filtering errors is essential.
Full Example Workflow Structure
[Start] → [Email Fetch] → [Loop Over Attachments] → [Notion Node (with error handling)]
↘ Success Output → Continue Processing
↘ Error Output → [Email Notification Node]
Common Mistakes and Troubleshooting
Mistake 1: Not Enabling "Continue Using Error Output"
- If you leave the setting on Stop Workflow, the entire automation halts on the first error.
- Solution: Change the On Error setting to Continue using error output to keep the workflow running.
Mistake 2: Forgetting to Connect Both Outputs of the Node
- When using error output, the node creates two outputs.
- Not connecting one of them can cause unexpected behavior or workflow stoppage.
- Solution: Always connect both success and error outputs appropriately.
Mistake 3: Not Logging or Notifying on Errors
- Ignoring errors silently can make it hard to debug issues later.
- Solution: Set up email notifications or logging nodes connected to the error output to capture and alert errors.
Mistake 4: Not Handling Partial Failures in Loops
- If one item in a loop fails, it might stop the entire loop.
- Solution: Use error handling on the nodes inside loops to continue processing other items.
For tips on making your workflows more reliable and scalable, see the Optimize n8n Workflows lesson.
Best Practices for Error Handling in n8n
- Always anticipate possible errors when calling external APIs or processing data.
- Use retry logic for temporary failures.
- Separate error outputs for clean handling of success and failure cases.
- Log errors with context (e.g., item URL, error message) for easier debugging.
- Notify your dev team immediately when critical errors occur.
- Test workflows thoroughly with both successful and failure scenarios.
For a comprehensive guide, consult the official n8n documentation on error handling{:target="_blank"}.
Additional Resources
Quick Reference Cheat Sheet
| Setting | Purpose | How to Use |
|---|---|---|
| Retry On Fail | Retry failed node executions | Enable and set max retries & interval |
| On Error: Stop Workflow | Default; stops workflow on error | Avoid for long-running automations |
| On Error: Continue (regular) | Continue with error passed in output | Use with an IF node to filter errors |
| On Error: Continue (error out) | Separate success and error outputs | Connect error output to logging/email |
| IF Node Expression | Detect errors in regular output | {{ $json.error !== undefined }} |
| Email Node | Send error notifications | Use expressions to pass error details |
By implementing the error handling techniques above, you ensure your n8n workflows are more fault-tolerant and easier to maintain, even when unexpected issues occur. As shown in the video above, this approach helps prevent workflow failures and provides valuable context for troubleshooting.