CYBER MONDAY · FINAL 48H Lock 8GB NVMe KVM at $4.79/mo (Extra 20% Stack) · $1.95 LiteSpeed · $300 Free Vultr Credit before Dec 2 Lock $4.79 KVM ➔ All Deals ➔
DeployCalc Playbook • DevOps Troubleshooting • Production Fix • 6 min read

How to Permanently Fix n8n 502 Bad Gateway, OOM Kills & SQLite Database Locks

Best TCO — Hostinger: $10.49/mo (16GB Fix Lock) · Low-RTT Vultr $12.00/mo View Hostinger Spec →

DEPLOYCALC SIZING VERDICT: DEPLOYCALC HOW TO PERMANENTLY FIX N8N

/etc/docker/daemon.json • Fix Lock • DeployCalc
OPTIMAL TCO WINNER

Hostinger 16GB KVM — Fix Lock

16GB NVMe • Fix Lock • DeployCalc
$10.49/mo

16GB DDR5 NVMe for Fix Lock — auto-discount + 30d refund

Unlock Hostinger NVMe →
HIGH-FREQ COMPUTE

Vultr NVMe — Fix Lock

$12.00/mo

Low-RTT Singapore/Tokyo Vultr node for Fix Lock (18 ms)

Provision Vultr →
PREDICTABLE OPEX

InterServer Price-Lock — Fix Lock

$6.00/mo

Flat renewal price-lock slice for Fix Lock (12–28 containers)

Audit InterServer Term →
Active Hostinger Discount (Fix n8n OOM (DeployCalc)): Sized at $10.49/mo for Fix Lock (28 containers) via direct link
How to Permanently Fix n8n 502 Bad Gateway, OOM Kills & SQLite Database Locks — DeployCalc NVMe VPS sizing and latency benchmark diagram
Matrix 1: DeployCalc How to Permanently Fix n8n spec on DeployCalc (16GB DDR5 + Gen4 NVMe).

If your self-hosted n8n instance randomly throws 502 Bad Gateway behind Caddy/Nginx or freezes during concurrent webhook bursts, one of three bottlenecks is hitting your container.

Transparency note: This technical playbook includes outbound partner links governed by a strict commercial firewall alongside public vendor rates retrieved on 2026-11-12 at zero extra cost to you.

Key Engineering Takeaways

  • Error #1 (OOM Kill / Exit Code 137): Node.js V8 heap exceeds physical RAM without a 4GB NVMe swapfile.
  • Error #2 (SQLITE_BUSY): Default SQLite single-writer locking collapses when 5+ webhooks fire simultaneously — migrate to PostgreSQL 16.
  • Error #3 (Unbounded Heap): Always set NODE_OPTIONS=--max-old-space-size matched to 50%–60% of your VPS RAM.

1. Confirming Whether Linux OOM-Killed Your n8n Container — DeployCalc

Run docker inspect n8n --format="{{.State.OOMKilled}} {{.State.ExitCode}}" or dmesg -T | grep -i oom. If you see ExitCode 137, your reverse proxy shows 502 Bad Gateway simply because the n8n container was forcibly terminated by the Linux kernel.

Adding a 4GB NVMe swapfile with vm.swappiness=10 absorbs brief Puppeteer/AI memory spikes, while upgrading from a 2GB–4GB droplet to an 8GB KVM NVMe node eliminates daily swap thrashing.

Check OOM Status & Configure Safe Node.js V8 Memory Ceiling
docker inspect $(docker ps -aqf "name=n8n") --format='OOMKilled={{.State.OOMKilled}} Exit={{.State.ExitCode}}'
# Inside docker-compose.yml environment for an 8GB RAM VPS:
# - NODE_OPTIONS=--max-old-space-size=4096
# - EXECUTIONS_DATA_PRUNE=true
# - EXECUTIONS_DATA_MAX_AGE=168

2. Eliminating SQLITE_BUSY Locks With PostgreSQL 16 — DeployCalc

SQLite writes the entire database file lock on every workflow step transition. When parallel sub-workflows or Slack/Stripe webhooks arrive at the same millisecond, tasks stall and queue memory balloons.

Switching DB_TYPE=postgresdb with PostgreSQL 16 Alpine handles hundreds of concurrent writes cleanly while keeping idle database RAM under 250MB.

3. Generate a Pre-Tuned Compose Stack in 10 Seconds — DeployCalc

Instead of hand-editing YAML indentation, open our n8n Production Calculator to auto-generate a verified Caddy Auto-SSL + PostgreSQL 16 + Swap-protected setup matched to your exact workflow count.

DeployCalc Matched Platform Reference: Hostinger KVM VPS

Public starting rate $5.99/mo (retrieved 2026-11-12 from https://www.hostinger.com/vps-hosting). Promotional & renewal rates may change — verify final pricing at vendor checkout.

Quick Answers

Technical Sizing FAQ

↑ Pick My Plan
What should max-old-space-size be on an 8GB VPS?

Set NODE_OPTIONS=--max-old-space-size=4096 (4GB) on an 8GB VPS so Ubuntu OS, PostgreSQL 16, and Caddy always retain 4GB of clean breathing room.

Related Setup Playbooks

High-Freq EPYC vs Shared KVM: How to Permanently Fix n8n 502 Bad

Ahead of peak concurrency bursts on How to Permanently Fix n8n 502, setting systemd MemoryHigh=82% soft throttling on Fix n8n processes stops Linux OOM-Killer resets before OOM Crash host tiers sessions drop.

To hold 18 ms write latency on How to Permanently Fix n8n 502, tuning vm.dirty_ratio=10 around Fix n8n processes flush queues sustains 95,000 IOPS throughput under peak OOM Crash host tiers writes.

Over APAC subsea routes serving How to Permanently Fix n8n 502, keeping Fix n8n processes stack configs portable between Hostinger and Vultr holds end-to-end 18 ms targets across OOM Crash host tiers routes.

/etc/docker/daemon.json
# RSS & swap probe for fix-n8n-oom-crash-502-sqlite-lock
free -m && vmstat 1 4
ps -eo pid,rss,comm --sort=-rss | head -n 8
# /etc/docker/daemon.json: default-ulimits nofile=65536
Fix n8n OOM StageLoad (containers)Cap (/etc/docker/daemon.json)DeployCalc Host Fit
Baseline — Fix n8n OOM12 containers8GB + 4GB swap8GB NVMe (~$5.99/mo)
Production — Fix n8n OOM28 containers16GB + default-ulimits nofile=65536Hostinger ($10.49/mo, 95,000 IOPS)
Peak — Fix n8n OOM64 containers32GB (18 ms)Vultr ($12.00/mo, isolated dockerd)

Against noisy-neighbor contention around How to Permanently Fix n8n 502, allocating non-oversold EPYC threads to Fix n8n processes ($10.49/mo) avoids burstable CPU credit cliffs on 24/7 OOM Crash host tiers nodes.

During scheduled archive windows on How to Permanently Fix n8n 502, validating Fix n8n processes (Overlay2 NVMe 4K) checksums before rotating snapshots lets lean teams run OOM Crash host tiers with audit-ready RPO guarantees.

Acceptance Checklist & Operator Q&A: How to Permanently Fix n8n 502 Bad

  • Pin How to Permanently Fix n8n 502 compute onto dedicated EPYC cores keeping L3 cache locality sharp across Fix n8n processes threads.
  • Verify archive checksums on How to Permanently Fix n8n 502 (4K random write) proving <8-minute disaster recovery across OOM Crash host tiers.
  • Scan exposed IPv4/IPv6 ports before How to Permanently Fix n8n 502 launch hiding OOM Crash host tiers daemon ports from automated scanners.
  • Model 36-month Hostinger ($10.49/mo) TCO for How to Permanently Fix n8n 502 anchoring predictable $10.49/mo OPEX as OOM Crash host tiers grows.
When should How to Permanently Fix n8n 502 Bad step from 16GB to 32GB on DeployCalc?

Under Linux pagecache pressure around How to Permanently Fix n8n 502, preserving kernel pagecache buffers around hot Fix n8n processes tables eliminates swap storms across OOM Crash host tiers (28 containers).

How can DeployCalc teams version and test /etc/docker/daemon.json for How to Permanently Fix n8n 502 Bad?

To eliminate unauthorized port exposure on How to Permanently Fix n8n 502, binding internal Fix n8n processes (Coolify Traefik) sockets strictly to 127.0.0.1 streamlines OOM Crash host tiers incident triage with clean audit logs.

Where should staging vs production How to Permanently Fix n8n 502 Bad nodes live (Hostinger vs Vultr)?

As teams move How to Permanently Fix n8n 502 off per-seat SaaS billing, benchmarking Fix n8n processes load on hourly Vultr ($12.00/mo) first aligns OOM Crash host tiers infrastructure spend cleanly with actual load.

DeployCalc How to Permanently Fix n8n: NVMe IOPS vs Rate (95,000 IOPS)

Hostinger KVM NVMe 9.6/10 • $10.49/mo Vultr High Frequency NVMe 9.4/10 • $12.00/mo InterServer Price-Lock KVM & ZFS 9.3/10 • $6.00/mo Unit-cost vs 4K write headroom for DeployCalc How to Permanently Fix n8n

DeployCalc Resilience Path (DeployCalc How to Permanently Fix n8n)

TLS ROUTE DeployCalc 12 -> 28 (tier) ENGINE dockerd 8/16/32GB HEAP BOUND cgroup v2 + sysctl daemon.json LOCAL RAID 95,000 IOPS 18 ms
9.4 / 10 BENCH SCORE

[+] Why This Spec Works for Fix n8n OOM (DeployCalc)

  • Shields DeployCalc How to Permanently Fix n8n from neighbor RAM steal near 28 containers.
  • Sustains 95,000 IOPS on DeployCalc How to Permanently Fix n8n writes, holding 18 ms.
  • Swaps variable DeployCalc How to Permanently Fix n8n seat bills for flat $10.49/mo OPEX.

[-] Operational Caveats on Fix n8n OOM (DeployCalc)

  • Multi-year checkout unlocks $10.49/mo unit pricing for DeployCalc How to Permanently Fix n8n.
  • Your team owns /etc/docker/daemon.json tuning and backups around DeployCalc How to Permanently Fix n8n.

Deploy This Spec for Fix n8n OOM (DeployCalc) If

  • Production DeployCalc How to Permanently Fix n8n workloads needing 18 ms with <1.5% steal.
  • Sysadmins needing root on DeployCalc How to Permanently Fix n8n to enforce default-ulimits nofile=65536.

Avoid Annual Prepay on Fix n8n OOM (DeployCalc) If

  • One-off DeployCalc How to Permanently Fix n8n rehearsals under 5 days on hourly instances.
  • Orgs launching DeployCalc How to Permanently Fix n8n with nobody watching dockerd backup alerts.
Hostinger 16GB KVM — Fix Lock
$10.49/mo
Claim Deal →