PlainError

FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory

Last checked 2026-11-11 · 2 fixes · reviewed answer

TL;DRThis error occurs when a JavaScript program, typically running in Node.js, tries to use more memory than the default limit allows and the system cannot allocate any more.

Most likely cause: The app needs more memory than Node.js allows by default

Try first: Check for obvious memory leaks in the code

Likely causes

  1. The app needs more memory than Node.js allows by defaultmost likely
  2. A memory leak in the JavaScript code is using up memory over timepossible
  3. The computer itself has very little available RAMless likely

How to fix it

Safest first: SafeChanges settingsDangerous
  1. Check for obvious memory leaks in the codeSafe

    Look for large arrays, objects, or loops that keep growing without being cleared, especially in long-running scripts or servers.

  2. Try running the script with a larger memory limitChanges settings

    Add the --max-old-space-size flag when starting Node.js to give it more heap space. Replace 4096 with a higher number if needed and use your actual script name.

    node --max-old-space-size=4096 yourscript.js

If that didn't fix it

Run the script with the Node.js inspector flag and capture a heap snapshot to inspect memory usage.

When to see a technician

If this happens on a production server or you cannot identify the memory-heavy part of the code, ask an experienced developer to review it.

Quick answers

What does FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory mean?
This error occurs when a JavaScript program, typically running in Node.js, tries to use more memory than the default limit allows and the system cannot allocate any more.
What causes FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory?
The app needs more memory than Node.js allows by default. (most likely) A memory leak in the JavaScript code is using up memory over time. (possible) The computer itself has very little available RAM. (less likely)
How do I fix FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory?
Try these in order, safest first: 1. Check for obvious memory leaks in the code. 2. Try running the script with a larger memory limit.
What if that didn't fix it?
Run the script with the Node.js inspector flag and capture a heap snapshot to inspect memory usage.
When should I see a technician?
If this happens on a production server or you cannot identify the memory-heavy part of the code, ask an experienced developer to review it.
Did this fix it? Report a problem

Related errors

All Coding errors →