How to Self-Host n8n on a VPS
Self-hosting n8n on a VPS gives you unlimited workflow executions at a fixed cost of ~$20–40/month. Set up a Hostinger or DigitalOcean VPS, install Docker, deploy n8n with docker-compose, configure SSL with Caddy, and set up automated backups.
On this page
n8n's cloud pricing charges per workflow execution. For GTM systems that run thousands of operations daily, this adds up fast. Self-hosting eliminates per-execution costs entirely — you pay a fixed VPS fee regardless of volume.
We self-host n8n for every GTMinds client. This guide covers the exact setup we use in production, from VPS selection to automated backups.
Why Self-Host n8n?
Unlimited executions — no per-workflow or per-operation fees. Run 100 or 100,000 executions/day at the same cost.
Data stays on your infrastructure — prospect data never leaves your server. Critical for GDPR compliance and clients in regulated industries.
Full control — install community nodes, configure memory limits, set custom environment variables, and access logs directly.
Cost predictability — fixed monthly VPS cost ($20–40) vs. variable cloud pricing that scales with usage.
Step 1: Choose and Provision a VPS
For n8n, you need a VPS with at least 4 GB RAM and 2 vCPUs. Our recommended setup:
Hostinger KVM 4 — 4 GB RAM, 4 vCPUs, 200 GB SSD. ~$600/year (roughly $50/month, often discounted to $20–30 with annual billing). This is what we use for most client deployments.
DigitalOcean — 4 GB RAM droplet at $24/month. Good alternative with simpler UX.
Hetzner — cheapest option (EU-based). 4 GB RAM at ~$7/month. Best value if you want European data residency.
Select Ubuntu 22.04 or 24.04 as your operating system. Once provisioned, SSH into your server.
Step 2: Install Docker
n8n runs as a Docker container, which makes installation and updates straightforward. Install Docker and Docker Compose on your VPS:
Update your system packages: sudo apt update && sudo apt upgrade -y
Install Docker using the official install script: curl -fsSL https://get.docker.com | sh
Add your user to the Docker group: sudo usermod -aG docker $USER
Install Docker Compose: sudo apt install docker-compose-plugin -y
Verify both are installed: docker --version && docker compose version
Step 3: Create the Docker Compose File
Create a directory for n8n and add a docker-compose.yml file. The compose file defines n8n, a PostgreSQL database for workflow storage, and Caddy as a reverse proxy for SSL.
Key configuration in your compose file:
n8n container — using the latest n8n image, with environment variables for database connection, webhook URL, timezone, and basic auth credentials
PostgreSQL container — for persistent workflow and execution data storage (SQLite works but PostgreSQL is more reliable at scale)
Caddy container — automatic SSL certificate provisioning and renewal. Point your subdomain (e.g., n8n.yourdomain.com) to your VPS IP address first
Set your n8n environment variables:
N8N_HOST — your subdomain (n8n.yourdomain.com)
WEBHOOK_URL — https://n8n.yourdomain.com/ (needed for webhook triggers to work)
N8N_BASIC_AUTH_USER / N8N_BASIC_AUTH_PASSWORD — protect the admin interface
GENERIC_TIMEZONE — set to your working timezone (e.g., Asia/Kolkata)
Step 4: Deploy and Verify
Before deploying, point a DNS A record for your subdomain (n8n.yourdomain.com) to your VPS IP address. Then:
Run: docker compose up -d
Wait 1–2 minutes for Caddy to provision the SSL certificate
Visit https://n8n.yourdomain.com — you should see the n8n login screen
Create your admin account and build a test workflow (e.g., webhook → respond with "Hello World")
Test webhooks by calling your test workflow URL. If you get a response, your n8n instance is fully operational with SSL.
Step 5: Set Up Automated Backups
Production n8n instances need automated backups. If your VPS fails, you need to restore all workflows and credentials quickly.
Database backup: Create a cron job that runs pg_dump daily and uploads the backup to cloud storage (S3, Google Cloud Storage, or even a simple rclone to Google Drive)
n8n workflow export: n8n has an API endpoint to export all workflows as JSON. Script this as a daily cron job alongside your database backup
VPS-level snapshots: Most VPS providers offer automated snapshots (Hostinger, DigitalOcean). Enable weekly snapshots as an additional safety net
Test your restore process at least once. A backup you have never tested is not a backup.
Step 6: Production Hardening
Before running real GTM workflows, apply these production settings:
Enable UFW firewall — only allow ports 22 (SSH), 80 (HTTP), and 443 (HTTPS)
Set up fail2ban — blocks repeated failed SSH login attempts
Use SSH keys instead of passwords — disable password authentication in sshd_config
Set Docker restart policies — add restart: unless-stopped to all containers so they come back after a server reboot
Monitor disk space — n8n execution logs can fill up disk. Set EXECUTIONS_DATA_PRUNE=true and EXECUTIONS_DATA_MAX_AGE=168 (7 days) to auto-prune
Cost Comparison
For context on why self-hosting matters:
n8n Cloud Starter: $20/month — 2,500 executions
n8n Cloud Pro: $50/month — 10,000 executions
Self-hosted on Hostinger: ~$25/month — unlimited executions
A typical GTM pipeline processing 2,000 leads/month through enrichment, scoring, and routing generates 20,000–50,000 workflow executions. On n8n Cloud that exceeds the Pro plan. Self-hosted, it costs the same $25/month regardless of volume.
Frequently asked questions
Neeraj Kumar
GTM Engineer / Revenue Systems Architect
Top 1% Global Clay Creator — engineered 50+ production GTM systems across B2B SaaS.
GTM engineering expert with 10+ years of enterprise B2B SaaS experience. Top 1% Clay Creator, 3x Clay Certified (97-99/100), and Teaching Assistant at Clay GTM Engineering School. Built $2M ARR from zero at Staqu, deployed 50+ GTM systems with 95% client retention. MBA from IIM Kozhikode. Specializes in Clay, n8n, AI automation, and revenue systems architecture.
- Top 1% Global Clay Creator
- All three Clay certifications
- MBA, IIM Kozhikode
- 10+ years enterprise B2B SaaS
Need a custom GTM playbook?
Book a free strategy call. We'll map your stack and recommend the right systems for your stage.