n8n Masterclass
0/24 complete

Module 02 · Workflow Architecture

Error Handling and Retry Logic in n8n

20 minfocused lesson5practical steps4grounded questions3source links
Open lesson + course map

On this lesson

Course outline

Retry only failures known to be temporary and safe to repeat. n8n supports node retry behavior and error workflows, but the workflow designer must classify errors and protect side effects.

// concept

Define the Error Taxonomy

// prompt — copy me9 lines
VALIDATION — bad/missing input; stop
AUTHENTICATION — expired/invalid identity; refresh through supported path or stop
AUTHORIZATION — forbidden; stop, never bypass
RATE_LIMIT — retry with provider guidance and cap
TEMPORARY — bounded backoff
CONFLICT — reconcile current state
TIMEOUT_UNKNOWN — query effect before retry
POLICY — stop and review
INTERNAL — alert with correlation ID

Return controlled codes, not raw secrets or stack traces to customers. Configure an error workflow to capture execution/workflow reference, safe error class, node, attempt, and owner.

// concept

Make Effects Idempotent

Before creating an order, message, invoice, or CRM record, establish a stable idempotency key from the triggering event and logical action. Store/check it in a durable authoritative service. n8n execution retry alone cannot guarantee external deduplication.

For TIMEOUT_UNKNOWN, query the provider using reference/idempotency key. Do not assume failure and repeat. Cap node attempts, workflow duration, and dead-letter age.

// worked_example

Worked Example

A courier booking call times out after submission. The workflow does not rerun create booking immediately. It calls get booking by client reference. If found, it stores the booking and continues; if confirmed absent and retryable, it retries using the same idempotency key.

An error workflow alerts Operations with execution_id, order_ref, class, attempt, and safe next step. The customer receives pending review, not a fabricated success.

// failure_cases

Failure Cases to Diagnose

6 cases to diagnose

  • Retry entire workflow

    resume from a checkpoint/effect ledger.

  • New key on each attempt

    keep logical identity stable.

  • 403 treated as transient

    stop and fix authorization.

  • Continue-on-error hides loss

    route and account for failed items.

  • Error workflow itself fails silently

    monitor and test it.

  • Execution data contains tokens

    redact and restrict retention.

// pakistan_angle

Pakistan Angle

Wallets, banks, couriers, SMS, and government services may time out. Always reconcile through the provider’s official status mechanism before duplicating a payment, filing, dispatch, or customer message.

Use PKT in operator alerts where useful, UTC for durable timestamps, and a published after-hours path. Avoid infinite retries during regional connectivity or load-shedding events; they multiply foreign-currency API cost.

// hands_on

Hands-On Exercise

5 steps

  1. Classify errors for every external node.

  2. create an error workflow.

  3. add stable idempotency to a sample write.

  4. simulate 429, 403, timeout-after-effect, and invalid input.

  5. prove replay creates one external record.

// completion_rubric

Completion Rubric

6 checks — tick as you verify

0/6

// sources

Sources

// check_yourself

Check yourself

4 questions · answers and options are taken word-for-word from this course

0/4
  1. 1 / 4 · diagnose

    Your work shows this failure mode: “New key on each attempt.” What does the lesson tell you to do about it?