How to Self-Host n8n on a VPS in 2026: RAM, Docker Compose & Real Cost
Self-hosting n8n Community Edition with PostgreSQL requires 2 GB RAM minimum and 4–8 GB RAM for reliable production webhooks. On Hostinger KVM 1 (4 GB) or KVM 2 (8 GB) with referral code XF3PLUTARXVF (-20%), total cost drops to ~$5.19–$7.03/mo with unlimited executions — saving $180–$500+/yr vs n8n Cloud.

Hardware Spec & Verified Rate Sheet: n8n
| Provider / Tier | Hardware & Architecture | List | Net Benefit | Code | Link |
|---|---|---|---|---|---|
Hostinger KVM 2 Recommended for n8n | 2 vCPU AMD EPYC · 8 GB DDR5 · 100 GB NVMe · 8 TB | $8.79/mo | ~$7.03/mo (-20%) | Claim -20% | |
Proton (VPN & Privacy) WireGuard + VPS Privacy | Gluetun WireGuard + NAT-PMP · Swiss No-Logs · Mail/Drive/Pass | Subscription | $20 USD credit | Claim $20 |
Measured RAM, vCPU & NVMe Profile for n8n
RAM spikes during large JSON/binary payloads & concurrent AI Agent webhooks
Production Deployment Stack (n8n)
services:
postgres:
image: postgres:16-alpine
restart: unless-stopped
environment:
POSTGRES_USER: n8n
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: n8n
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U n8n"]
interval: 10s
timeout: 5s
retries: 5
deploy:
resources:
limits:
memory: 1G
n8n:
image: docker.n8n.io/n8nio/n8n:latest
restart: unless-stopped
depends_on:
postgres:
condition: service_healthy
ports:
- "127.0.0.1:5678:5678"
environment:
DB_TYPE: postgresdb
DB_POSTGRESDB_HOST: postgres
DB_POSTGRESDB_DATABASE: n8n
DB_POSTGRESDB_USER: n8n
DB_POSTGRESDB_PASSWORD: ${POSTGRES_PASSWORD}
N8N_HOST: ${N8N_DOMAIN}
N8N_PROTOCOL: https
WEBHOOK_URL: https://${N8N_DOMAIN}/
N8N_ENCRYPTION_KEY: ${N8N_ENCRYPTION_KEY}
N8N_DEFAULT_BINARY_DATA_MODE: filesystem
EXECUTIONS_DATA_PRUNE: "true"
EXECUTIONS_DATA_MAX_AGE: "168"
GENERIC_TIMEZONE: UTC
volumes:
- n8n_data:/home/node/.n8n
deploy:
resources:
limits:
memory: 4G
volumes:
postgres_data:
n8n_data:sudo ufw default deny incoming && sudo ufw allow 22/tcp && sudo ufw allow 80,443/tcp && sudo ufw enable
mkdir -p /opt/n8n && cd /opt/n8n
printf "POSTGRES_PASSWORD=%s\nN8N_ENCRYPTION_KEY=%s\nN8N_DOMAIN=n8n.yourdomain.com\n" "$(openssl rand -hex 24)" "$(openssl rand -hex 32)" > .env
chmod 600 .env
docker compose up -d && docker compose logs -f n8nCritical Operational Insights
UFW Firewall, TLS & WireGuard / ProtonVPN Hardening
Bind n8n strictly to 127.0.0.1:5678 behind Caddy or Traefik with automatic TLS 1.3. Never expose port 5678 directly to 0.0.0.0. For workflows scraping geo-sensitive endpoints or private APIs, attach an egress Gluetun + ProtonVPN WireGuard container so outbound webhook IPs stay isolated.
5AA9X0DA).Claim US$20 on ProtonDeploy on Verified Infrastructure
Hostinger KVM 2
Proton VPN & Unlimited
Frequently Asked Questions
Which Hostinger VPS plan is best for n8n?
KVM 1 (4 GB RAM, ~$5.19/mo with code XF3PLUTARXVF) handles solo n8n + PostgreSQL cleanly. Choose KVM 2 (8 GB RAM, ~$7.03/mo) if you also run Coolify, Puppeteer/Playwright nodes, or high-concurrency AI workflows.
Is n8n Community Edition really free to self-host?
Yes. Under n8n's Sustainable Use License, self-hosting for internal business or personal automation is free with zero execution caps — you only pay for your VPS.


