schoolLearn

VPS Hosting for n8n

Self-host n8n workflow automation on budget VPS infrastructure (Hetzner, DigitalOcean) with Docker, persistent databases, and zero task execution caps.

timer
Time to Value20-30 minutes
signal_cellular_alt
DifficultyIntermediate

The Goal:

"Self-hosted n8n instance running 24/7 on dedicated VPS with unlimited workflow executions and persistent database"

Phase 1: Understand

Self-hosting n8n on an affordable VPS is one of the highest-ROI infrastructure decisions an automation team can make. While n8n Cloud charges $20 to $120+ per month with strict execution caps, self-hosting n8n on a $4 to $10/month VPS gives you unlimited workflow runs, custom community nodes, and local data residency.

Sizing and System Requirements

- **Minimum:** 1 vCPU, 2 GB RAM (good for light testing).

- **Recommended Production:** 2 vCPU, 4 GB RAM with NVMe SSD (e.g. Hetzner CX22 for ~€3.79/mo).

- **Database:** Always pair n8n with PostgreSQL in production. The default SQLite database is suitable only for local prototyping and will suffer from concurrency locks under heavy webhook volume.

Operational Responsibilities

When self-hosting, you own the uptime and security of your instance. Essential maintenance includes enabling execution data pruning, scheduling automated PostgreSQL dumps to remote S3 storage, and firewalling unused ports.

verifiedBest Practices

Use External PostgreSQL Over SQLite

For production workloads with frequent triggers, always configure PostgreSQL rather than default SQLite to prevent database locks.

Prune Execution History Periodically

Configure EXECUTIONS_DATA_PRUNE=true and EXECUTIONS_DATA_MAX_AGE=168 (7 days) to keep disk space under control.

warningCommon Mistakes

Underprovisioning RAM

Running n8n on a 1 GB RAM VPS causes out-of-memory container crashes during concurrent webhook triggers.

check_circle

Provision at least 2 GB (preferably 4 GB) of RAM.

Exposing Unencrypted HTTP Webhooks

Running webhooks over plain HTTP exposes API credentials and payload data in transit.

check_circle

Always terminate SSL via reverse proxy (Caddy, Traefik, or Cloudflare).

Your Action Roadmap

Check off steps as you go to track your momentum.

1. Server Provisioning

Launch an unmanaged Ubuntu Linux VPS with adequate compute for concurrent automation runs.

check_circle

Expected Result

Fresh Ubuntu 24.04 server with 2 vCPUs and 4 GB RAM.

lightbulb

Pro Tip

Hetzner CX22 (€3.79/mo) or DigitalOcean $6/mo Droplet provide ample power for tens of thousands of daily workflows.

2. Install Docker & Compose

Set up the container runtime engine on the host server.

buildDocker Engine
check_circle

Expected Result

Docker and docker-compose plugin installed and enabled as a systemd service.

lightbulb

Pro Tip

Use the official Docker convenience script: curl -fsSL https://get.docker.com | sh.

3. Configure PostgreSQL & n8n Compose

Set up production-grade state persistence and execution history pruning.

buildDocker Compose
check_circle

Expected Result

Production docker-compose.yml running n8nio/n8n alongside PostgreSQL 16.

lightbulb

Pro Tip

Always configure EXECUTIONS_DATA_PRUNE=true and EXECUTIONS_DATA_MAX_AGE=168 to prevent runaway disk usage.

4. Reverse Proxy & SSL Termination

Expose secure HTTPS webhooks to external services like Stripe, Slack, and OpenAI.

buildCaddy / Traefik
check_circle

Expected Result

Automated Let's Encrypt certificate issuance on your custom domain.

lightbulb

Pro Tip

Set WEBHOOK_URL=https://n8n.yourdomain.com in environment variables so webhook URLs are correctly formatted.

Phase 2: Compare
starEditor's Choice

The Ultimate Starter Stack

Don't want to overthink it? Use this battle-tested combination of tools.

Coolify 1-Click Stack

Easiest self-hosted setup with automated GUI management.

Hetzner Cloudadd
Traefikadd
PostgreSQL

Estimated Cost

$4 - $10/month (VPS cost only; n8n software is free)

per month

Docker Compose on VPS Stack

alt_route

Direct root control without intermediate control planes.

Tech Stack

Docker ComposeUbuntu 24.04CaddyDigitalOcean

Managed Railway Stack

alt_route

PaaS convenience without server maintenance.

Tech Stack

Railwayn8n DockerRailway PostgreSQL
Phase 4: Act
boltAct Now

Ready-to-Use Prompts

Copy and paste these exact prompts into your AI tools to get immediate results.

Docker

Production n8n Compose Template

12
// Production n8n Compose Template
Generate a production docker-compose.yml file for n8n with PostgreSQL 16, persistent volumes, environment pruning, and automated Caddy reverse proxy.
lightbulb

Pro Tip: Set N8N_ENCRYPTION_KEY explicitly to avoid losing credential encryption on rebuild.

Frequently Asked Questions

Between $4 and $10/month. The n8n Community Edition is free and open-source. You only pay for the VPS server (e.g. Hetzner at ~€3.79/mo or DigitalOcean at $6/mo).

A 2 vCPU / 4 GB RAM VPS on Hetzner can easily process tens of thousands of workflow executions daily when backed by PostgreSQL with execution pruning enabled.

You are responsible for periodic VPS security updates (apt upgrade), database backups (Postgres pg_dump), and monitoring disk space.

Explore More Goals

Keep Discovering AI

Follow AIToolsHaven for new AI tools, workflows and useful AI resources.

homeHomeexploreExplore
add
bookmarkBookmarkspersonAccount