Handle Errors in Your Workflows

Difficulty
2/10
Tags
EssentialsHTTP RequestManual TriggerEdit Fields (Set)Error Handling

In the last lesson you learned to find and fix bugs in your workflows: typos in expressions, wrong field names, that kind of thing. Those are problems in your workflow. But sometimes the problem isn't your code. APIs go down. Servers hiccup for a few seconds. OpenAI returns a 500 error out of nowhere. Your workflow is fine, but the thing it's talking to isn't.

If you haven't planned for this, your workflow just stops. And you might not even notice until a client asks why something didn't happen.

I learned this the hard way. I had an error workflow set up to ping me on Discord whenever something failed. One night I woke up to a thousand Discord messages. A workflow kept failing on a schedule trigger, and each failed run sent another notification. The workflow was supposed to fetch items from a table, process them, and mark them as done. But because the processing step kept failing, it never marked anything as done, so it kept picking up the same items, failing, and notifying me again. A fun introduction to idempotency at 3am.

One thing n8n does well here: errors are visible. Each official node has built-in error handling, so errors don't get silently swallowed. You see exactly what failed and where. That makes it much easier to deal with than chasing invisible bugs in code.

Watch the video below. Michele covers the five main error handling techniques in n8n: retry on fail, continue on error, split error route, fallback LLM, and error workflows. After the video, the challenge has you configure two of these on a real workflow. Finding the settings yourself and understanding when to use each one is where the learning happens.

What you'll practice:

  • Configuring Retry on Fail in node settings
  • Setting up a Split Error Route with success and error branches
  • Watching Retry on Fail handle real, random API failures

Your Task

  1. 1Copy the exercise below
  2. 2Paste into your n8n editor (Ctrl+V)
  3. 3Solve it — use hints if you get stuck
  4. 4Check the solution when done

Build a workflow that fetches data from a flaky API and handles errors gracefully:

We built an API endpoint that randomly fails about 40% of the time (returning 500 or 503 errors), just like real APIs do in production: https://www.node-bench.com/api/lessons/error-handling/flaky

  1. Add a Manual Trigger and connect an HTTP Request node to the flaky API URL above
  2. In the HTTP Request node's Settings tab, turn on Retry on Fail (3 retries, 1000ms wait between tries)
  3. In the same Settings tab, set On Error to Continue (using error output) to create a split error route
  4. Connect an Edit Fields node to the success output (top connector). Map the quote from $json.data.quote into a field called quote and add a status field set to "success"
  5. Connect another Edit Fields node to the error output (bottom connector). Map the error message and add a status field set to "error"

Test it: Run the workflow several times. Sometimes it'll succeed on the first try. Sometimes Retry on Fail will kick in and save it. Sometimes all retries fail and the error branch fires. That's exactly what happens with real APIs.

Get the exercise workflow

Create a free account to copy exercises into your n8n editor.

Hints

  1. Add a Manual Trigger node to start the workflow
  2. Add an HTTP Request node. Set method to GET and URL to https://www.node-bench.com/api/lessons/error-handling/flaky
  3. Click the HTTP Request node, go to the Settings tab (not Parameters)
  4. Toggle Retry on Fail to on. Set max retries to 3 and wait between tries to 1000
  5. Find the On Error dropdown and select Continue (using error output)
  6. Back on the canvas, notice the node now has two output connectors instead of one
  7. The top connector is the success output, the bottom one is the error output
  8. Drag from each output to a new Edit Fields node
  9. In the success Edit Fields: add a field quote with value {{ $json.data.quote }} and a field status with value "success"
  10. In the error Edit Fields: check the output panel to see what error fields are available, then map the error message and add a status field set to "error"
  11. Run the workflow several times. The API fails randomly, so you'll see both branches fire across different runs

Explanation

When the flaky API returns a 500 or 503 error, the HTTP Request node retries automatically (because of Retry on Fail). If all retries fail, instead of stopping the workflow, it passes the error to the second output (because of the Split Error Route). Each technique serves a different purpose.

Retry on Fail handles temporary glitches. APIs go down for seconds at a time, especially LLM APIs like OpenAI or Claude. Three retries with a one-second wait fixes most of these without you even noticing.

Split Error Route (On Error: Continue using error output) gives you two paths within the workflow: one for when things work, one for when they don't. Useful when you need custom error handling for a specific step.

Error Workflow (covered in the next lesson) catches errors across all your workflows and sends notifications. This is the most important technique for production workflows because you set it up once and it covers everything.

Continue on Error (On Error: Continue) seems tempting but usually makes things worse. The workflow keeps going with empty or broken data, and downstream nodes process garbage without you knowing. Only use it when the next step genuinely doesn't depend on the current one.

Fallback LLM is specific to AI Agent nodes. If your primary model goes down, n8n tries a backup. Connect a different provider (Claude as backup for OpenAI, or vice versa) so a single outage doesn't break your agent.

Copy the Solution

Paste into n8n with Ctrl+V to compare with your approach.

How was this lesson?

Get the solution workflow

Create a free account to copy solutions into your n8n editor.

Related Content

Continue your learning journey with these related lessons and guides: