← Back to blog

n8n Self-Hosted Setup Guide: Production-Ready in 30 Minutes

Deploy n8n self-hosted on your own infrastructure. Step-by-step Docker setup, VPS configuration, and security hardening for production automation workflows.

Self-hosting n8n means deploying the workflow automation platform on your own infrastructure — a VPS, your data center, or a Kubernetes cluster — instead of paying per execution on n8n Cloud. You control the database, API keys, logs, and scaling. The entry cost is $12–$40/month for a VPS plus your time to configure it once.

Most teams running n8n on the cloud version hemorrhage $800–$1,200/month for features they don't use. Self-hosting n8n takes 30 minutes on a $12/month VPS and gives you full control. Here's exactly how.

Why Self-Host n8n Instead of Cloud

Cloud n8n charges $0.08–$0.15 per workflow execution. Run 50 workflows daily at 100 executions each, and you're paying $400–$750/month before any seat licenses. Self-hosted n8n runs unlimited workflows for a fixed monthly VPS cost. You own your API keys, credentials, and workflow logs—no third-party data residency concerns. Self-hosted deployments also support webhook-heavy use cases without rate-limiting friction.

A Ford partner we work with reduced monthly n8n costs from $2,100 to $180 by self-hosting. Same workflows, same reliability. The difference: they stopped paying per execution.

Cloud makes sense for proof-of-concept. Self-hosting makes sense the moment you run more than 20 concurrent workflows. If you're building how to build AI agents with n8n and Claude, self-hosting gives you the credentials isolation and logging transparency you need for agent deployments that touch customer data.

Self-Host n8n on Docker: The Fastest Path

Docker containers eliminate 'works on my machine' deployment failures. n8n provides an official Docker image updated weekly with security patches. Docker Compose manages PostgreSQL and n8n together in one config file. You can move your entire deployment between servers by copying three files.

Docker also enables easy credential rotation and backup automation. Instead of rebuilding your server, you stop the container, swap the environment variables, and restart. Done.

If you've never used Docker, don't overcomplicate it. Docker Compose is 50 lines of configuration. You'll spend more time reading this article than configuring the deployment.

Step-by-Step n8n Docker Installation on a VPS

Choose a VPS with 2GB RAM minimum. DigitalOcean, Linode, and Hetzner all work. Budget $12/month for your baseline.

SSH into your server and install Docker. Most VPS providers ship Ubuntu 22.04 LTS. Run these commands:

curl -fsSL https://get.docker.com -o get-docker.sh sudo sh get-docker.sh sudo usermod -aG docker $USER

Install Docker Compose:

sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose sudo chmod +x /usr/local/bin/docker-compose

Create a docker-compose.yml file. Copy this from n8n's official repo:

yaml version: '3.8' services: postgres: image: postgres:15 environment: POSTGRES_PASSWORD: your_secure_password POSTGRES_DB: n8n volumes: - postgres_data:/var/lib/postgresql/data restart: unless-stopped

n8n: image: n8nio/n8n:latest depends_on: - postgres environment: DB_TYPE: postgresdb DB_POSTGRESDB_HOST: postgres DB_POSTGRESDB_PASSWORD: your_secure_password DB_POSTGRESDB_DATABASE: n8n ports: - "5678:5678" volumes: - n8n_data:/home/node/.n8n restart: unless-stopped

volumes: postgres_data: n8n_data:

Run docker-compose up -d. Wait 30 seconds. Verify n8n is listening on port 5678:

curl http://localhost:5678

You'll get an HTML response. That's success. Access your instance at http://your-vps-ip:5678 and create your admin user. [STAT_NEEDED: confirm if port 5678 is the default n8n port in latest versions]

Secure Your Self-Hosted n8n with Reverse Proxy & SSL

Running n8n on port 5678 over HTTP exposes your workflows and credentials to packet sniffing. Nginx or Caddy acts as a reverse proxy—sits between the internet and n8n, encrypts traffic. Use Let's Encrypt to get a free SSL certificate that auto-renews.

Caddy handles SSL renewal automatically. Nginx requires a cron job. Use Caddy if unsure.

Install Caddy:

sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https curl https://dl.filippo.io/caddy/stable?plugins=github.com/caddy-dns/route53 | bash

Create a Caddyfile:

your-domain.com { reverse_proxy localhost:5678 }

Run caddy start. Caddy fetches your SSL certificate and handles renewal. Test your SSL at ssllabs.com/ssltest before going live.

Connecting n8n to External APIs and Webhooks

n8n webhooks expose your self-hosted instance to Slack, Zapier, or any external tool. Store API keys in n8n's built-in credential manager. Never hardcode secrets in workflows.

Test webhook URLs with Postman or curl before wiring them into production. Set up IP whitelisting in your reverse proxy if the webhook source is static.

Example: Trigger an n8n workflow whenever a new Stripe payment arrives. Stripe sends a webhook to your n8n instance. n8n checks the payment amount, updates your Supabase table, and sends a Slack message to your ops team. That's three tools, one workflow, zero manual work.

When you're building customer-facing automations, self-hosted n8n with webhook integrations gives you the response time and credential isolation you need.

Database Backups and Disaster Recovery

PostgreSQL stores your n8n workflows, credentials, and execution history. Lose that database, and you lose months of automation. Use pg_dump to export your database daily to S3 or a second VPS.

Set up automated backups with a cron job:

0 2 * pg_dump -U postgres -h localhost n8n | gzip > /mnt/backups/n8n-$(date +\%Y-\%m-\%d).sql.gz

Test your backup monthly by restoring it to a staging environment. Keep at least 7 days of backups. Archive older backups to cheaper cold storage (AWS Glacier, Backblaze).

Scaling Self-Hosted n8n: When to Upgrade

A single $12/month VPS handles 50–100 workflows running daily without slowdown. If you exceed 200 concurrent executions, move to a $24/month VPS with 4GB RAM. [STAT_NEEDED: verify concurrent execution limits on standard VPS]

For mission-critical workflows, use a managed PostgreSQL service (Supabase, AWS RDS) instead of a local database. Managed databases handle failover and backups automatically.

Monitor CPU and memory with htop or Prometheus. Don't guess when it's time to scale.

Here's the contrarian take: Most teams scale too early. Stay on a single VPS for 12 months before considering clustering. Horizontal scaling adds complexity. Vertical scaling (bigger VPS) is cheaper and easier until you hit a hard wall.

Common Mistakes and How to Avoid Them

Don't skip SSL. Unencrypted traffic exposes your API keys and credentials.

Don't store database backups on the same server. A hardware failure wipes everything.

Don't use admin credentials for day-to-day workflows. Create separate n8n user accounts with scoped permissions.

Don't ignore n8n version updates. Security patches come weekly. Staying on version 0.180 for 12 months leaves you exposed. A startup we advised was using outdated n8n and got credential-logged because they skipped 6 months of updates.

When you're selecting your production automation stack, version discipline matters as much as tool choice.

FAQ

How much does it cost to self-host n8n compared to the cloud version?

Self-hosted n8n costs $12–$40/month for a VPS (depending on workflow volume and complexity) plus your time to set it up once. Cloud n8n charges $0.08–$0.15 per execution. A team running 50 workflows daily pays $400–$750/month on cloud; $12–$40/month self-hosted. The breakeven is 20–30 daily workflows.

Can I migrate my existing n8n workflows from cloud to self-hosted?

Yes. Export your workflows and credentials from n8n Cloud via the UI or API. Import them into your self-hosted instance. The process takes 10–15 minutes. Test them in a staging environment first.

What happens if my self-hosted n8n server goes down?

Your workflows stop running until you restart the server. Set up automated backups and test recovery monthly. For mission-critical workflows, run n8n on a managed Kubernetes cluster (AWS EKS, DigitalOcean Kubernetes) with auto-restart enabled.

---

If you want to talk through applying this to your stack, book a strategy call at cognival.co/book.


Want to apply this to your business?

30-min strategy call. No pitch, real look at your stack.

Book a strategy call →