BLACK FRIDAY 2026 LIVE: RackNerd 4GB VPS $47.98/yr (Lifetime) · ElevenLabs 55% Off · Hostinger 73% Off · Amazon Local AI Hardware View Verified Deals →
6 min readReal Lab Measurements

n8n + PostgreSQL 16 Production Hardening: Prevent OOM Kills, Disk Full & Webhook 502 (2026)

TL;DR

90% of self-hosted n8n outages come from three misconfigurations: unbounded execution logs filling the disk, missing 2 GB swap causing Linux OOM kills, and mismatched WEBHOOK_URL headers causing 502/OAuth failures. Apply the 4-step hardening block below to keep n8n + PostgreSQL 16 running for months unattended.

Top 4 Self-Hosted n8n Production Failure Modes & Exact Fixes
Symptom / Log ErrorRoot CauseVerified FixPrevention Metric
Container exits with code 137Linux OOM Killer (RAM spike > limit)Add 2 GB swap + NODE_OPTIONS=--max-old-space-size=2048Keep peak RSS < 70% of node RAM
SQLITE_BUSY / database is lockedConcurrent webhooks hitting SQLiteMigrate to PostgreSQL 16 (31 MB idle RSS)Zero write-lock retries
No space left on device (ENOSPC)Unpruned binary/JSON execution logsEXECUTIONS_DATA_PRUNE=true + MAX_AGE=168Disk usage flat < 55%
Secure cookie / OAuth redirect_uri_mismatchHTTP mismatch or missing WEBHOOK_URLCaddy 443 TLS + WEBHOOK_URL=https://domain/HTTP 200 on /healthz

1. Why Default n8n Docker Tutorials Break in Week 3

Most quickstart posts run n8n on SQLite with default log retention. Once an AI agent runs every 5 minutes storing JSON tool responses, the SQLite database balloons past 15 GB, causing sluggish UI loads and sudden ENOSPC crashes.

Switching to PostgreSQL 16 adds only ~31 MB idle RSS (confirmed on our live Linux 6.8 host) while enabling safe concurrent writes and instant pg_dump snapshots without stopping n8n.

2. Backing Up N8N_ENCRYPTION_KEY Alongside PostgreSQL

A PostgreSQL dump is useless without your N8N_ENCRYPTION_KEY because stored OAuth tokens and API keys are encrypted at rest. Store your .env encryption key inside your password manager separately from the database dumps.

3. Fast Triage for Webhook 502 & TLS Certificate Errors

When Caddy logs ACME HTTP-01 errors, verify your DNS A record points directly to the server IP (or use Cloudflare DNS-01 / Tunnel) and confirm `ss -tulpn | grep -E ":80|:443"` shows no leftover Apache or Nginx process competing for port 80.

Verified Production Commands

# 1. Verify swap & container health
swapon --show && docker stats --no-stream --format "table {{.Name}}\t{{.MemUsage}}\t{{.CPUPerc}}"

# 2. Automated nightly PostgreSQL 16 backup (add via crontab -e)
0 3 * * * docker exec nodebudget-postgres pg_dump -U n8n n8n | gzip > /root/backups/n8n-$(date +\%F).sql.gz && find /root/backups -name "n8n-*.sql.gz" -mtime +14 -delete

Related Engineering Deep-Dives