n8n 'Cannot Read Properties of Undefined' Error

Workaround available n8n Cloud, self-hosted Updated October 21, 2026

Quick answer

This error means a node or Code node tried to read a field from data that doesn't exist, often because a previous node returned nothing or a different shape. Inspect the input data, guard against empty items, and make sure workers run the same version.

Most likely fix: Inspect the input data.

Symptoms

A node or Code node fails with 'Cannot read properties of undefined (reading ...)', or the whole run fails with 'Problem running workflow'.

Why it happens

  • Previous node returned no items or a different JSON structure
  • API (e.g. OpenAI) returned an error or empty response
  • Expression references a node that didn't run on this branch
  • Main instance and queue workers on different n8n versions

How to fix it

Try these in order — the most common fix is first.

  1. 1. Inspect the input data

    1. Open the failing node and check the Input panel
    2. Confirm the field you reference actually exists
    3. Run the previous node alone to see its real output
  2. 2. Guard against missing data in Code nodes

    1. Use optional chaining, e.g. $input.first()?.json
    2. Check items.length before accessing items
    3. Return an empty array or default value when data is missing
  3. 3. Handle API errors before parsing

    1. Verify credentials and model or endpoint names
    2. Add retries on the API node (Settings > Retry On Fail)
    3. Add an IF node to skip empty responses
  4. 4. Align versions in queue mode

    1. Make sure the main instance and all workers run the same n8n version
    2. Update n8n to the latest stable release

This guide also covers

  • n8n cannot read properties of undefined
  • n8n code node error
  • n8n problem running workflow
  • n8n reading 'node'

Still not working?

If n8n keeps failing, you're not alone. See every n8n problem users report or the alternatives people switch to.

Other n8n errors