How to Self-Host n8n on a VPS: A Practical Guide
Self-hosting n8n is simpler than it looks: a small always-on VPS, Docker, a domain and HTTPS. This guide covers the Docker and npm install, the env vars that matter, security and upkeep, backups and the encryption key - and when you should just use n8n Cloud instead.

Table of contents
Running your own n8n instance is one of those tasks that looks intimidating from the outside and turns out to be a couple of commands and a bit of upkeep. This is a practical, honest guide to self-hosting n8n on a VPS — what you need, how to install it, how to keep it secure, and when you should just pay for n8n Cloud instead.
What you actually need
n8n is lightweight. You do not need a beefy machine — a small, always-on VPS is the whole requirement. A box with 1–2 GB of RAM is plenty for personal and small-team workflows; you scale up only if you are running heavy, high-frequency automations. The non-negotiables:
- A VPS you control (any mainstream provider works).
- A domain or subdomain pointed at it, so you can reach the editor over HTTPS.
- Docker installed — this is the recommended install path and the least painful to maintain.
The "always-on" part matters more than raw power. n8n needs to be running to catch webhooks and fire scheduled workflows, so a VPS beats your laptop. The same reasoning we laid out in Cloud Agents vs Self-Hosted Agents: When Should Code Leave the Laptop? applies here almost word for word.
Installing: Docker or npm
There are two common paths.
Docker (recommended). Pull the official image, mount a volume so your workflows and credentials persist across restarts, and map the port. A minimal run looks like:
docker volume create n8n_data
docker run -d --restart unless-stopped \
--name n8n \
-p 5678:5678 \
-v n8n_data:/home/node/.n8n \
docker.n8n.io/n8nio/n8n
For anything beyond a quick test, use Docker Compose so your config, environment, and a reverse proxy live in one file you can version-control.
npm. If you have Node installed you can run npm install n8n -g and start it with n8n. It works, but for a server you will still want a process manager and a reverse proxy, so Docker usually ends up simpler in the long run.
Config and environment basics
n8n is configured largely through environment variables. The ones you will touch first:
N8N_HOSTandWEBHOOK_URL— set these to your real domain so webhook URLs generated by n8n are publicly reachable and correct.N8N_PORT/ protocol settings — align with your reverse proxy.N8N_ENCRYPTION_KEY— n8n encrypts stored credentials with this key. Back it up. Lose it and you lose access to every saved credential.- Database: n8n defaults to SQLite, which is fine to start. For anything you rely on, point it at PostgreSQL so your data lives in a real, backup-friendly database.
Put n8n behind a reverse proxy (Caddy or Nginx) to terminate TLS, and enable basic auth or the built-in user management so the editor is not open to the world.
Security and upkeep — the honest part
This is where self-hosting earns its keep and also demands your attention. When you run n8n yourself, you own updates, security, and uptime. Nobody else is watching it. The baseline checklist:
- HTTPS only. Never expose the editor over plain HTTP.
- Lock down access with authentication and, ideally, a firewall that only opens the ports you need.
- Update regularly. New n8n releases ship fixes; pull the new image and restart on a cadence.
- Back up the database and — critically — the encryption key. Test that a restore actually works before you need it.
- Watch your webhooks. A public webhook endpoint is an open door; validate incoming requests where it matters.
If that list makes you uneasy, that is useful information. The security discipline is the same we described in Securing AI Coding Agents: Sandboxes, Permissions and Audit Logs — sandboxing, least privilege, and audit trails apply to an automation engine just as much as to a coding agent. For a more hands-on walkthrough of standing up a service on a VPS from scratch, How to Host Your Own AI Agent (Without a DevOps Team) covers the same ground from the agent angle.
When to use n8n Cloud instead
Self-hosting is the right call when you want to keep data on infrastructure you control, avoid per-task metering, and you are comfortable running a server. But be honest about the tradeoff. If your team has no appetite for maintenance windows, backups, and patching — or you just want to build workflows today and not think about ops — n8n Cloud is the managed option that handles the servers, updates, and uptime for you. It is also the fastest way to get started and see whether n8n fits before you invest in your own instance.
Many teams do both: prototype on the cloud, then move to self-hosted once a workflow proves its worth and the data-ownership argument kicks in. Where n8n slots into the broader picture is covered in the ideal solo-developer stack.
The bottom line
Self-hosting n8n is genuinely accessible: a small VPS, Docker, a domain, HTTPS, and a habit of updating and backing up. Do that and you get a private, unmetered automation engine you fully control. If the upkeep is not for you, the managed cloud removes all of it.


