How to Self-Host n8n on a VPS with Docker (2026 Guide)
This tutorial was written with AI assistance from the project's official documentation. Verification status is stated at the end of the article.
What is n8n and why self-host it
n8n (short for "nodemation", pronounced n-eight-n) is a fair-code workflow automation platform with native AI capabilities.
It pairs a visual canvas with the ability to drop into JavaScript, Python, and npm packages when a node-based flow isn't enough, and it ships with 1500+ integrations plus 9,000+ community workflow templates.
You can build multi-step AI agents that call OpenAI, Anthropic, Google, or open-source models and switch providers without rewriting your architecture.
Self-hosting matters here for two reasons. First, workflows routinely touch credentials, customer data, and internal APIs, so keeping execution inside your own infrastructure is a real security property, not a slogan.
Second, n8n is source-available under the Sustainable Use License and the n8n Enterprise License, so you can run it anywhere, extend it with custom nodes, and audit what it does.
The project does not publish a memory requirement, so size your VPS based on the workflows you plan to run rather than a documented number.
Prerequisites and server setup
You need a Linux VPS with Docker installed and a user that can run docker (either root or a member of the docker group).
The README's quick start uses the official image docker.n8n.io/n8nio/n8n and exposes port 5678.
No database, cache, or other dependency service is required by the documented setup: n8n stores its state in the /home/node/.n8n directory inside the container, which is why the README creates a named volume called n8n_data and mounts it there.
Before you start, point a DNS A record (for example n8n.example.com) at your server's public IP. You'll use that hostname when you put a reverse proxy in front of n8n for HTTPS.
Step-by-step installation with Docker
The README gives a single docker run command. The equivalent Compose file below keeps the same image, the same port mapping, and the same named volume, and adds a restart policy so the container comes back after a reboot.
services:
n8n:
image: docker.n8n.io/n8nio/n8n
container_name: n8n
restart: unless-stopped
ports:
- "5678:5678"
volumes:
- n8n_data:/home/node/.n8n
volumes:
n8n_data:
Save this as docker-compose.yml in a directory such as /opt/n8n.
The README does not document any environment variables for the basic setup, so the minimal file above needs no .env.
If you later add configuration (for example, to set the public URL behind a proxy), create a .env file next to the compose file and reference variables under an environment: block; consult the official Docker hosting docs at https://docs.n8n.io/hosting/installation/docker/ for the exact variable names rather than guessing.
Start the stack:
docker compose up -d
Check that it came up and is listening on the expected port:
docker compose ps
docker compose logs -f n8n
The first launch initializes the n8n_data volume. That volume is the only thing holding your workflows, credentials, and SQLite database, so back it up before upgrades.
Accessing the dashboard and reverse proxy
Once the container is running, open http://<your-server-ip>:5678 in a browser. That is the editor, and it is the same URL the README points to at http://localhost:5678 when running locally.
On first visit n8n asks you to create an owner account.
To serve it over HTTPS, put a reverse proxy in front of port 5678. Two common choices:
- Caddy on the host: a two-line Caddyfile with
n8n.example.com { reverse_proxy 127.0.0.1:5678 }gets you automatic Let's Encrypt certificates. In that case, bind the container to localhost only by changing the port mapping to"127.0.0.1:5678:5678"so the editor isn't reachable directly on the public IP. - Nginx Proxy Manager in its own container: create a proxy host for
n8n.example.com, forward to your server's IP on port5678, and enable the SSL tab with a new Let's Encrypt certificate.
Whichever you pick, make sure the proxy forwards WebSocket upgrade headers, since the editor uses them.
If you terminate TLS at the proxy, review the n8n Docker hosting documentation for the environment variables that tell n8n its public URL and trust the proxy; those names are not listed in the README.
Wrapping up
n8n gives you a full automation and AI-agent platform on a single VPS with one container and one volume, and the upgrade path is just pulling a newer image and restarting.
The project is at https://github.com/n8n-io/n8n, with documentation at https://docs.n8n.io and community support at https://community.n8n.io.
Measured in our sandbox run: total memory 675.5 MB (sum of per-container peaks over a 30s idle window after startup) across 1 container; largest container 675.5 MB; published port(s) 5678; HTTP probe returned 200. The run took 118.7s including the image download.
Verification: we ran this docker-compose stack in a disposable Docker environment and recorded the measurements above. They describe that run, not a guarantee for your host.
Originally published with full interactive benchmark metrics and server sizing notes at https://benchrun.pages.dev/self-host-n8n-docker-vps/.
Comments
No comments yet. Start the discussion.