// guides · n8n error index

n8n static data not saving? 35 runs, every cause found

Fix n8n $getWorkflowStaticData not saving: manual runs never save, reassigning, failed runs, parallel lost updates and Date/Map loss. Tested on n8n 2.43.7.

Updated 2026-10-29 · about 10 minutes

Still stuck after these steps? Paste your exact n8n error and we'll reproduce it and email you the fix, free →

Steps

  1. How we tested, and what is real

    On 29 October 2026 we ran about 35 real executions on a self-hosted n8n 2.43.7 (SQLite, Node 24). Each workflow used $getWorkflowStaticData() in a Code node, and after every run we read the saved static data straight from the n8n database. We tested production webhook calls, editor (manual) runs, the CLI, a server restart, failing runs, parallel calls, and the data types that survive. Every result below is what we saw.

  2. Quick answer: only production runs save static data

    Static data is saved only when an active (published) workflow runs from its production trigger: a production webhook URL, a Schedule Trigger, a polling trigger. When we clicked run in the editor, the Code node read the stored value and returned the incremented count, but the database never changed: the next manual run returned the same number again. The test webhook URL runs in manual mode too (per the n8n docs). So if your counter or "last ID" never moves while you test, it is working as designed. Activate the workflow and call the production URL.

  3. Mutate the object, do not replace it

    const s = $getWorkflowStaticData('global'); s.count = (s.count || 0) + 1; saved every time (1, 2, 3, still 4 after restarting n8n). But let s = $getWorkflowStaticData('global'); s = { count: 1 }; never saved anything: three runs returned 1, 1, 1 and the database stayed empty. n8n saves the object it handed you, so change its properties. Nested changes work: s.obj.n++ and s.list.push(x) both persisted.

  4. A failed execution throws your writes away

    When the Code node wrote a new value and then threw an error, the webhook got HTTP 500 Error in workflow and nothing was saved, three times in a row. Static data is only written at the end of a successful execution. If a later node fails, your "last processed ID" stays at the old value and the next run processes the same items again. Either let the run succeed (On Error: Continue on the risky node) or accept the replay and remove duplicates.

  5. Parallel runs lose updates

    We sent 3 webhook calls at the same moment to a workflow that read the counter, waited 1.5 s, and wrote count + 1. All three returned 1, and after a 4th call the stored count was 2, not 4. Each execution saves its own copy at the end, and the last one wins. Static data is not a lock or a safe counter. For counters or queues hit in parallel, use a database, Redis (INCR) or a Data Table, or limit the workflow to one execution at a time.

  6. Dates, Maps and undefined do not survive

    Static data is stored as JSON. A Date came back on the next run as a string (typeof returned string), a Map came back as an empty object {} with its data gone, and keys set to undefined were dropped. Store dates as ISO strings or timestamps, and use plain objects and arrays.

  7. Global or node scope

    $getWorkflowStaticData('global') is shared by every node in the workflow. $getWorkflowStaticData('node') is stored per node under a key with the node name, for example node:Code, so two Code nodes do not see each other's node data. If you read from one node and write from another, use global.

  8. The "remember the last ID" pattern

    This worked across runs in our tests (IDs 1, 6, 11, then 15 stored):

    const s = $getWorkflowStaticData('global');
    const last = s.lastId || 0;
    const fresh = $input.all().filter(i => i.json.id > last);
    if (fresh.length) s.lastId = Math.max(...fresh.map(i => i.json.id));
    return fresh;
    Run it on an active workflow, and remember that a failed run later in the workflow will not move lastId.

  9. See or reset the stored value

    Download the workflow as JSON: when static data exists it is in the staticData field. Importing the same workflow again with the CLI kept the existing static data in our test. To reset it, run once with code that deletes the keys (delete s.lastId) from a production trigger, since manual runs do not save.

All test results

Real executions on n8n 2.43.7, with static data read from the database after each run.

TestResult
Production webhook, global count x31, 2, 3 saved; after restart next call returned 4
Editor (manual) run x2Returned 3 twice; database stayed at 2 (not saved)
CLI n8n execute --idSaved (1, then 2)
Reassign the variable (s = {...})Returned 1, 1, 1; nothing saved
Nested s.obj.n++, s.list.push()Saved: {"obj":{"n":3},"list":[1,2,3]}
Code node writes then throws500 Error in workflow x3; nothing saved
3 parallel calls, read, wait 1.5 s, writeAll returned 1; stored count 2 after a 4th call (lost updates)
Store a DateNext run got a string
Store a MapNext run got {} (data lost)
Key set to undefinedDropped
Node scopeStored under node:<node name>
lastId pattern, ids 1, 6, 11Only new items returned each run; lastId 15 stored
Re-import workflow with the CLIExisting static data kept

Checklist

Good to know

What we did not test

n8n Cloud, queue mode with several workers, Postgres as the n8n database, renaming a node that holds node-scope data, and polling trigger nodes that use static data internally.

FAQ

Why is n8n static data not saving?

In our tests it was saved only by production executions of an active workflow. Editor runs and the test webhook URL read it but never save it. It is also lost when you reassign the variable or when the execution fails.

Does $getWorkflowStaticData work in manual executions?

It reads the stored value, but changes are not saved. Our manual runs returned the same count twice while the database did not change.

Is n8n static data kept after a restart?

Yes. Our counter continued from 3 to 4 after restarting n8n, because it is stored in the database with the workflow.

Can I use n8n static data as a counter for parallel executions?

Not safely. Three simultaneous runs all read the same value and the last save won, so updates were lost. Use Redis INCR, a database or a Data Table.

How do I reset n8n workflow static data?

Delete the keys in a Code node and run it from the production trigger, since manual runs do not save. You can see the current value in the staticData field of the downloaded workflow JSON.

Related guides

New guides

Still stuck on your n8n error?

Paste the exact error and say what the workflow should do. We reproduce it on a real n8n install and email you the fix or a working workflow, usually within 24h. Free while we're in beta.

We'll only email you about your error and TaskToAgent.