Hi everyone,
I’m having ongoing issues with my self-hosted n8n instance and I’m not sure what the real root cause is. The editor is extremely slow, often stuck on “Loading…” or “Redirecting…”, and many times I end up with a 502 Bad Gateway. The server itself looks totally fine (16GB RAM, low CPU usage), but the n8n container keeps restarting.
In the logs I repeatedly get:d
FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
and also a lot of:
ValidationError: The ‘X-Forwarded-For’ header is set but trust proxy is false
I’m running n8n in Docker with Traefik, and I’m still using SQLite as the database. I also have many active workflows (webhooks + scheduled workflows), so I’m starting to think SQLite might be overloading n8n during startup and causing the memory spikes.
My idea for fixing this:
I’m thinking of doing the following:
- Switch from SQLite to PostgreSQL, because it seems more stable for setups with many active workflows.
- Increase the Node.js memory limit (
NODE_OPTIONS=--max_old_space_size=8192) so n8n can use more than 4GB RAM. - Enable
N8N_TRUST_PROXY=trueto stop the Traefik header validation errors.
Before I change the whole setup, I just want to check if this approach makes sense or if you recommend doing something differently.
Any feedback or best-practice advice would be really appreciated!