n8n: FATAL ERROR: JavaScript heap out of memory
Last verified
FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memoryWhat it means
This is a Node.js crash message, printed in the server logs of a self-hosted n8n instance. Node's V8 engine has a cap on how much memory its "old space" heap can use, and n8n exceeded it. The process exits, so every running execution stops; in the editor you typically see Execution stopped at this node or a lost connection.
The heap cap can be lower than the machine's RAM, so a server with plenty of free memory can still hit it. n8n's docs say to raise the old-space size for this specific error, and to reduce memory use in workflows in any case.
What is not wrong: your workflow logic may be correct. It is processing more data at once than the process is allowed to hold.
What it looks like
# docker-compose.yml
environment:
- NODE_OPTIONS=--max-old-space-size=4096Why it happens
- The V8 old-space limit is lower than what the workload needs.
- Workflows load large datasets or binary files into a single execution.
- Many concurrent executions on one instance.
- Execution data for very large runs being kept in memory.
How to fix it
- Raise the heap limit with the NODE_OPTIONS environment variable, for example --max-old-space-size=4096 (megabytes), keeping it below available RAM.
- Restart n8n and confirm the setting is applied.
- Reduce per-execution data with batching and sub-workflows.
- Limit concurrency or move to queue mode with workers if many heavy workflows run together.
- Check container memory limits so the container is not killed before the heap limit is reached.
How to stop it recurring
Size the instance for your largest workflow, set the heap limit explicitly, monitor memory, and keep heavy processing in batches. Raising the limit buys headroom but does not replace batching.
Official documentation: docs.n8n.io/hosting/scaling/memory-errors. See all n8n error messages or the n8n limits and quotas.
Related errors
Definitions
Quick answers
What does "FATAL ERROR: JavaScript heap out of memory" mean in n8n?
This is a Node.js crash message, printed in the server logs of a self-hosted n8n instance. Node's V8 engine has a cap on how much memory its "old space" heap can use, and n8n exceeded it. The process exits, so every running execution stops; in the editor you typically see Execution stopped at this node or a lost connection.
How do I fix "FATAL ERROR: JavaScript heap out of memory"?
1. Raise the heap limit with the NODE_OPTIONS environment variable, for example --max-old-space-size=4096 (megabytes), keeping it below available RAM. 2. Restart n8n and confirm the setting is applied. 3. Reduce per-execution data with batching and sub-workflows. 4. Limit concurrency or move to queue mode with workers if many heavy workflows run together. 5. Check container memory limits so the container is not killed before the heap limit is reached.
Error handling you can see in the workflow
Autonoly workflows have per-node retries, timeouts, continue-on-fail and error-handler branches, so a failing step can be retried or routed instead of stopping the whole run. Saved workflows have no loop node; lists are worked through by the AI agent or one run per trigger item.
Also see Visual workflow builder.