Half the people searching this want their AI agent to stop forgetting the conversation. The other half have a server that keeps crashing. These are unrelated problems — pick yours.
Adding server RAM won’t fix this. Chat memory in n8n is a workflow-level feature: the AI Agent only remembers what a memory node feeds back into the prompt. The three usual causes:
| Symptom | Cause | Fix |
|---|---|---|
| Forgets between messages | No memory node, or each run gets a new session | Attach a memory node and pass a stable session key (e.g. the chat/user id) — not a random or empty one |
| Forgets after restart or randomly in production | Simple Memory lives in the n8n process RAM — a restart wipes it; in queue mode each worker has its own copy, so runs land on different memories | Use persistent chat memory: Redis Chat Memory or Postgres Chat Memory node — mandatory in queue mode (per n8n docs) |
| Remembers only the last few messages | Context window limit of the memory node / model | Raise the window length consciously — every remembered message is re-sent as prompt tokens and costs money |
Source: n8n docs on Simple Memory (“not shared between workers in queue mode”) — that queue caveat is the single most common production surprise.
Answer three questions — get a diagnosis grounded in n8n's own benchmark and measured community reports, plus a copy-paste guard config.
Your guard config
Caps the container and pins Node's heap so failures become graceful instead of random. Numbers are computed for the RAM you selected.
# Memory guard for n8n on a 2 GB box — paste into your docker-compose service
services:
n8n:
# hard cap: container dies cleanly at 1.5G instead of freezing the whole VPS
mem_limit: 1.5g
environment:
# Node heap ≈60% of the box — n8n fails at a known line, not randomly
- NODE_OPTIONS=--max-old-space-size=1229
# n8n 2.x: task runners have their own heap — cap it separately
- N8N_RUNNERS_MAX_OLD_SPACE_SIZE=307
# stop hoarding successful runs in the DB (big RAM/disk saver):
# - EXECUTIONS_DATA_SAVE_ON_SUCCESS=none
# watch it live for a week and adjust: docker stats
Cloud plans don't let you touch memory settings — and community reports show AI Agent flows crashing on Cloud Starter that run clean on a self-hosted 8 GB box. If you're migrating to your own server, size it honestly first: our calculator turns your workload into RAM / vCPU / disk, a cost comparison, and a ready docker-compose kit.
Size my server →