The Short Answer
You can self-host n8n on a VPS, and the route n8n itself now recommends is Docker — specifically Docker Compose on a 64-bit Linux server. Checked against n8n’s official documentation on December 4, 2026, the current Compose guide asks for Docker Engine with Docker Compose v2 and at least 4 GB of RAM with 2 vCPUs, runs n8n on port 5678, and stores its data in a persistent volume mounted at /home/node/.n8n. That volume holds the database file (SQLite by default) and, critically, the encryption key that makes your saved credentials readable — lose it and the credentials are gone even if the workflows survive.
Two decisions separate a test install from a production one. First, the database: n8n’s docs say SQLite is fine for trying things out, but a production instance with more than a handful of users or workflows running around the clock should use PostgreSQL. Second, exposure: n8n’s production requirements are explicit — do not expose the n8n process directly to the internet; put a reverse proxy or load balancer with TLS in front of it, and tell n8n its public hostname so webhook URLs come out right. One more 2026 change matters before you start: from n8n 3.0, the old npm installation route is no longer supported for self-hosted installs, so a Docker-based deployment is now required, not optional. If Docker itself is new to you, work through our guide on how to install Docker on a VPS first, then come back.
Why Self-Host n8n at All?
n8n is a workflow automation tool: you connect apps and APIs with visual workflows, run on triggers, schedules, and webhooks. Self-hosting means that engine — plus every workflow, credential, and execution log — runs on a server you control. The reasons are practical: workflows can reach services on your own network, history and API keys stay on your infrastructure, and cost is the server, not a per-execution plan.
The trade is equally practical. n8n states that self-hosting requires technical knowledge — servers and containers, resource management, security, and n8n configuration — recommends it for expert users, and warns mistakes can mean data loss, security issues, and downtime. If you already run services yourself, it fits alongside the setups in our roundup of the best VPS options for self-hosting. If this is your first server, budget the learning curve, not just the VPS.
Step 1: Size the VPS Before You Install Anything
The most common sizing mistake is buying the smallest VPS on the page. n8n is a continuously running Node.js application, and its memory use grows with the data your workflows move. The official Compose guide’s floor is 4 GB of RAM and 2 vCPUs, because the stack includes a sandbox that runs AI-generated code using Docker-in-Docker, which needs more headroom than a typical container.
Treat that as a floor, not a target. One user with light scheduled workflows will live at the minimum; PostgreSQL on the same box, several users, bursty webhooks, or file-heavy workflows mean stepping up — RAM first. Execution history and binary data also accumulate until pruning, so choose SSD storage with room to grow. Our VPS sizing guide on how much CPU, RAM and storage you actually need covers the general method.
One structural warning: the sandbox runner runs privileged with Docker-in-Docker, which n8n describes as weak isolation — escaped code reaches the host. n8n advises a dedicated host or VM with nothing else on it. Give n8n its own server.
Step 2: Install Docker and Bring n8n Up
On a headless Linux VPS, install Docker Engine and the Docker Compose v2 plugin (Docker Desktop is for machines with a graphical environment). Verify with docker compose version — Compose v2 is a hard prerequisite, and the old standalone docker-compose binary is not a substitute.
n8n documents two paths. The one-line setup creates the project, generates secrets, and starts the stack — the fastest way to an editor at http://localhost:5678. The hand-built Compose setup suits full control: a project folder, a .env file with the n8n version and sandbox secrets (kept out of version control), and services in compose.yml. Either way you get n8n, the sandbox stack for n8n Assistant, and a bundled search backend, with SQLite in the n8n-data volume by default.
Copy three details exactly. Persist the volume (docker volume create n8n_data, mounted at /home/node/.n8n) so workflows, credentials, and the encryption key survive recreation. Set the timezone with both TZ and GENERIC_TIMEZONE — one for system commands, one for schedule nodes — or workflows fire at baffling hours. Enforce settings-file permissions with N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true. Start with docker compose up -d and verify curl -sf http://localhost:5678/healthz before touching DNS.
Step 3: Choose the Database — SQLite to Test, PostgreSQL to Run
Make this decision on day one, because moving later is the painful version. n8n’s Compose guide is direct: SQLite is fine for trying things out, but a production instance with more than a handful of users or workflows running around the clock should use PostgreSQL. The production requirements add two hard edges: n8n does not support SQLite in queue mode, and does not recommend it for multi-user production use.
| SQLite (default) | PostgreSQL | |
|---|---|---|
| Setup | Built in, stored in the n8n-data volume | Extra service in Compose, credentials in .env |
| Good for | Testing, single user, light schedules | Production, multiple users, 24/7 workflows |
| Queue mode | Not supported | Required |
| Data growth | One file; execution history inflates it | Proper database; back it up like one |
| Migration | — | Set DB_TYPE=postgresdb plus host, port, database, user, password |
Adding PostgreSQL means a postgres service with its own volume and health check, n8n pointed at it with DB_TYPE=postgresdb and the DB_POSTGRESDB_* variables, and n8n waiting on the healthy condition. Two warnings matter. The guide uses Postgres 18, which changed its default data directory — set PGDATA=/var/lib/postgresql/data, or the database comes up empty after the next recreate. And existing SQLite data does not carry over automatically — the documented setup is for a fresh instance. Choose PostgreSQL before you build real workflows, and keep the n8n-data volume mounted anyway: it still holds the encryption key and logs.
Step 4: Domain, Reverse Proxy, and Webhooks
Create a DNS record for a hostname such as n8n.example.com. Put a reverse proxy in front of n8n — n8n explicitly says not to expose the process directly to the internet — and terminate TLS at the proxy. Then tell n8n where it lives: N8N_HOST takes the hostname, N8N_EDITOR_BASE_URL and N8N_WEBHOOK_URL take the full https:// URLs (WEBHOOK_URL before 2.30.0), and N8N_PROXY_HOPS makes n8n trust forwarded headers. Skip this and webhook URLs come out as http://...:5678, which external services cannot call.
Firewall accordingly: the proxy reaches n8n on 5678; n8n reaches PostgreSQL on 5432 and Redis on 6379 in queue mode; the task broker on 5679 stays private. Only the proxy’s 443 faces the internet. Our guide on how to secure your VPS covers the baseline to have in place first.
Step 5: Backups, the Encryption Key, and Updates
The encryption key is the instance. n8n encrypts stored credentials with a key kept in the data directory (or set via N8N_ENCRYPTION_KEY). The production checklist calls for generating one — openssl rand -hex 32 — storing it securely, and using the same value on every instance. Back it up separately from the database: a perfect database backup restored without the matching key gives you workflows whose credentials cannot be decrypted.
Back up both stores. With SQLite, that is the n8n-data volume. With PostgreSQL, it is the database volume plus the still-mounted n8n-data volume. Test a restore before you need one; an untested backup is a hope.
Update on the stable channel, deliberately. n8n releases a new minor version most weeks; the docs describe stable as the production channel and beta as the most recent release, which may be unstable. At our check on December 4, 2026, the Docker guide listed current stable as 3.4.4 and current beta as 3.5.3. The Compose rhythm is docker compose pull, docker compose down, docker compose up -d — never down -v, which deletes your volumes. Pin the version in .env, read release notes for breaking changes (the 3.0 line already removed the npm route), and back up before a major-version jump.
When Self-Hosting Is the Wrong Answer
Self-hosting wins when workflows must reach private services, data should stay on your infrastructure, or volume makes a fixed server cost beat a usage plan. It loses when nobody wants to own patching, TLS, backups, and a database — n8n Cloud exists for that case, and n8n recommends it for anyone not experienced at managing servers. The honest test is not “can I install it?” but “who fixes it in month six?” If the answer is nobody, pay for the managed version.
FAQ
What size VPS do I need to self-host n8n?
Start with at least 2 vCPUs and 4 GB of RAM — the floor in n8n’s official Docker Compose guide, checked December 4, 2026, because the bundled sandbox runs Docker-in-Docker and needs headroom. Add PostgreSQL on the same server, multiple users, or file-heavy workflows, and step up in RAM first.
Can I run n8n on SQLite in production?
n8n’s docs say SQLite is fine for trying things out, but production instances with more than a handful of users or workflows running around the clock should use PostgreSQL. SQLite is not supported in queue mode and is not recommended for multi-user production. Choose PostgreSQL on day one if the instance will do real work — existing SQLite data does not migrate automatically.
Why do my webhook URLs show the wrong address?
Because n8n builds them from its own protocol, host, and port unless you tell it otherwise. Behind a reverse proxy, set N8N_HOST to your hostname, N8N_WEBHOOK_URL (or WEBHOOK_URL before 2.30.0) to the full public https:// URL, and N8N_PROXY_HOPS so n8n trusts the proxy’s forwarded headers. Restart, then copy a webhook URL from the editor to confirm it shows your domain.
What happens if I lose the n8n data volume?
You lose the encryption key, and with it the ability to decrypt every stored credential, even if you restore the database. Back up the n8n-data volume (and your PostgreSQL volume, if used), store the key separately, test a restore, and never run docker compose down -v on a production stack.
Is the npm install still an option?
Not for new self-hosted installs on current versions. n8n’s production requirements state that from n8n 3.0, npm installations are no longer supported and a Docker-based deployment is required. Use Docker Engine with Compose v2, or the one-line setup that builds the Compose stack for you.
Should n8n share a VPS with my other services?
Prefer not to, if you use the bundled sandbox stack. n8n’s Compose guide warns that the sandbox runner runs privileged with Docker-in-Docker — weak isolation, where escaped code reaches the host — and advises a dedicated host or VM with nothing else on it.
The Bottom Line
Self-hosting n8n on a VPS in 2026 is a Docker job with three non-negotiables: a server that meets the documented floor (2 vCPUs, 4 GB RAM, 64-bit Linux, Docker Engine with Compose v2), a persistent volume whose encryption key you back up like it matters — because it is the instance — and a reverse proxy with TLS in front, with the public hostname configured so webhooks work. Add PostgreSQL from the start if the instance will run real, around-the-clock work; SQLite is for testing, and its data does not migrate itself. Respect the sandbox warning and give n8n a dedicated server, update on the stable channel with a backup first, and the result is an automation platform whose workflows, credentials, and history live entirely on infrastructure you control. Skip any of those steps and you have not saved money — you have deferred a bill that arrives as downtime.
Sources: n8n official documentation, checked December 4, 2026 — “Install with Docker” (docs.n8n.io/hosting/installation/docker/): Docker recommended for most self-hosting, expert-user warning, stable 3.4.4 / beta 3.5.3 at check time, port 5678, n8n_data volume at /home/node/.n8n, GENERIC_TIMEZONE/TZ, SQLite default with PostgreSQL via DB_TYPE=postgresdb, Compose update sequence. “Install using Docker Compose” (docs.n8n.io/deploy/host-n8n/install-options/install-using-docker-compose.md): Docker Engine + Compose v2, at least 4 GB RAM and 2 vCPUs, sandbox Docker-in-Docker privileged warning and dedicated-host advice, SQLite fine for testing / PostgreSQL for production, Postgres 18 PGDATA warning, SQLite data not auto-migrated. “Production requirements” (docs.n8n.io/deploy/host-n8n/install-options/production-requirements.md): 64-bit Linux recommended, npm installs unsupported from n8n 3.0, ports 5678/5432/6379/5679, reverse proxy in front (do not expose n8n directly), TLS at the proxy, N8N_HOST / N8N_EDITOR_BASE_URL / N8N_WEBHOOK_URL and N8N_PROXY_HOPS, encryption key generation. No VPS prices are quoted; verify current server pricing on your chosen provider’s own page before ordering.



Leave a Reply