How Do You Self-Host n8n on a VPS?
We run n8n on our own Hetzner box in production. It replaced Zapier. Here is the setup, the backups, and the parts nobody warns you about.
Self-hosting n8n means running it in Docker behind a reverse proxy with Postgres, not SQLite, and a backup job you have actually restored. The install takes an afternoon. The real work is the database, queue mode when volume grows, and the backups you test before you need them.
You self-host n8n by running it in Docker next to a Postgres database and putting a reverse proxy in front of it. The whole stack is a docker compose file with three services: n8n, Postgres, and a proxy like Caddy or Traefik that handles TLS.
In This Guide
How do you self-host n8n on a VPS?
What breaks when you self-host n8n?
How do you back up a self-hosted n8n?
Is self-hosting n8n worth it?
4 Tips to Get Started
Use Postgres from day one, not the default SQLite. SQLite is fine for a demo and a dead end for anything with real volume.
Set the encryption key and the webhook URL as environment variables and back them up. Lose the encryption key and every stored credential is gone.
Put n8n behind a reverse proxy with TLS. Never expose port 5678 to the internet directly.
Run the backup job on a schedule and restore it into a throwaway container once a quarter. An untested backup is a hope.
Ready to Stop Worrying About Infra?
Knowledge is the first step. Get a free 1-hour diagnostic and see where your infrastructure leaks time, money, and focus.
Sources & References
- n8n Docs: Hosting n8n
- n8n Docs: Docker installation
- n8n Docs: Database and environment variables
- Docker Docs: Compose file reference
roqy.io cites authoritative sources including engineering blogs, vendor documentation, industry surveys, and academic research to ensure accuracy.
Related Guides
n8n vs Zapier: The Real Cost Math for a Self-Hosted Stack
Zapier charges $20-100+ a month by task volume. Self-hosted n8n on a $5 VPS is free after the box. Here is the honest cost math and when each one actually wins.
How to Self-Host Supabase with Docker Compose
Self-host Supabase with Docker Compose: the services it runs, the config you must change, and the backup story the hosted version hides from you. A DevOps walkthrough.
Dokploy vs Coolify: Which Self-Hosted PaaS Should You Run?
Dokploy and Coolify both turn a VPS into a Heroku. Here is how they differ on Docker, Traefik, databases, and backups, and which one fits a small team.
Fly.io vs Railway: Which Should You Deploy To?
Fly.io runs your app close to users on micro-VMs. Railway is a simpler PaaS with a nicer DX. Here is how they differ on pricing, networking, and databases.
Ron Cohen — Founder & DevOps Engineer
Content reviewed by the roqy.io team. Our guides are based on publicly available data and cited sources above.
Disclaimer: This content is for informational and educational purposes only. It does not constitute professional advice or a guarantee of specific results. Infrastructure needs vary by team, stack, and stage. Consult a qualified engineer for advice tailored to your situation.
Frequently Asked Questions
How do I self-host n8n on a VPS?
Run n8n in Docker with a Postgres database, put it behind a reverse proxy with TLS, and set the encryption key and webhook URL as environment variables. A docker compose file with n8n and Postgres is enough to start. Add queue mode with Redis when your workflow volume grows.
Is self-hosting n8n free?
The software is free under the fair-code license. You pay for the VPS, usually $5-20 a month, and your own time for setup and maintenance. Compared to a Zapier plan at $20-100 a month, the box pays for itself quickly if you run real volume.
What breaks when you self-host n8n?
The common failures are a full disk from execution logs, a webhook URL that points at the wrong host after a move, memory pressure when many workflows run at once, and an upgrade that changes a node. None are fatal if you watch disk, memory, and the changelog.
How do I back up a self-hosted n8n?
Back up two things: the Postgres database with pg_dump and the encryption key from your environment. The database holds the workflows and credentials, and the key decrypts the credentials. Back up both, store them off the server, and test a restore.
Get the DevOps Ecosystem Behind You
One accountable engineer. Full platform behind him. Month-to-month, no lock-in.