Tutorial
How to Install n8n on a VPS with Docker in 30 Minutes (2026)
Updated 2026-06-13 · by Fahmi Fahreza
To install n8n on a VPS with Docker, provision a VPS with at least 2 vCPU/2 GB RAM, point a domain to the server, run n8n via Docker Compose with a reverse proxy for HTTPS, then secure it with a firewall. The whole process takes about 30 minutes.
How do you install n8n on a VPS with Docker?
To install n8n on a VPS with Docker: provision a VPS with at least 2 vCPU/2 GB RAM, point a domain to the server's IP, then run n8n using Docker Compose with a reverse proxy for HTTPS. After that, lock the server down with a firewall and user management. If your VPS and domain are ready, the whole process can be done in about 30 minutes.
Self-hosting gives you full control over your data, stable costs even as workflow executions grow, and the freedom to add as many nodes as you need. This guide assumes an Ubuntu 22.04/24.04 VPS and that you want n8n running on your own domain (for example n8n.yourdomain.com).
What do you need before you start?
Before typing any commands, make sure these four things are in place:
- A VPS running Ubuntu (22.04 or newer) with root/sudo SSH access.
- A domain or subdomain whose DNS you can manage (for HTTPS and a clean URL).
- The right specs for your workload (see the table below).
- Basic terminal familiarity, enough to copy-paste commands and edit a file.
Here is a VPS spec guide based on your needs:
| Workload | vCPU | RAM | Storage | Notes |
|---|---|---|---|---|
| Testing / personal | 1-2 | 2 GB | 20 GB SSD | Fine for a few light workflows |
| Small business | 2 | 2-4 GB | 40 GB SSD | Ideal for WhatsApp + CRM + light AI |
| Production / AI agent | 4 | 4-8 GB | 60-100 GB SSD | Many parallel executions and LLM calls |
For an Indonesian audience, choose a Singapore or Jakarta server location for low latency. A standard VPS typically costs a few dollars per month, depending on the provider and specs.
What are the steps to install n8n with Docker Compose?
Follow these steps in order. Replace n8n.yourdomain.com and the email with your own.
-
Log into the VPS via SSH and update the system.
ssh root@YOUR_VPS_IP apt update && apt upgrade -y -
Install Docker and the Docker Compose plugin.
curl -fsSL https://get.docker.com | sh apt install docker-compose-plugin -yVerify with
docker --versionanddocker compose version. -
Point your domain to the server. In your domain's DNS panel, create an A record for
n8n.yourdomain.compointing to your VPS public IP. Wait for DNS propagation (usually a few minutes to an hour). -
Create a project folder and config file.
mkdir ~/n8n && cd ~/n8n nano docker-compose.yml -
Fill in
docker-compose.ymlwith an n8n + Caddy setup (Caddy handles HTTPS automatically via Let's Encrypt):services: n8n: image: n8nio/n8n:latest restart: always environment: - N8N_HOST=n8n.yourdomain.com - N8N_PROTOCOL=https - WEBHOOK_URL=https://n8n.yourdomain.com/ - GENERIC_TIMEZONE=Asia/Jakarta volumes: - n8n_data:/home/node/.n8n caddy: image: caddy:latest restart: always ports: - "80:80" - "443:443" volumes: - ./Caddyfile:/etc/caddy/Caddyfile - caddy_data:/data volumes: n8n_data: caddy_data: -
Create a
Caddyfilein the same folder for the reverse proxy + automatic HTTPS:n8n.yourdomain.com { reverse_proxy n8n:5678 } -
Start n8n.
docker compose up -dCaddy will fetch the SSL certificate automatically. Open
https://n8n.yourdomain.comin your browser and create your first owner account. -
Enable the firewall (UFW) so only the needed ports are open:
ufw allow OpenSSH ufw allow 80 ufw allow 443 ufw enable
After step 8, your n8n instance is live on your own domain with HTTPS enabled.
How do you secure a self-hosted n8n instance?
Once n8n is running, security is the next priority. At a minimum, do the following:
- HTTPS is mandatory, already handled by Caddy/Traefik in the steps above; never expose n8n over plain HTTP.
- User management / authentication, create the owner account on first launch, and add basic auth at the reverse proxy if you want an extra layer.
- Firewall (UFW), close every port except 22 (SSH), 80, and 443.
- Regular updates, periodically pull the latest image (
docker compose pull && docker compose up -d) to patch security holes. - Back up your data, the
n8n_datavolume holds all your workflows and credentials; back it up regularly to separate storage.
For production scale, consider moving the database from the built-in SQLite to PostgreSQL and scheduling automated backups.
When should you self-host vs use n8n Cloud?
Not every business needs to self-host. Here is a quick comparison:
| Aspect | Self-host (VPS + Docker) | n8n Cloud |
|---|---|---|
| Data control | Full (your own server) | Managed by n8n |
| Cost | Stable, starts at a few dollars/month | Subscription per execution/seat |
| Maintenance | Your responsibility | Automatic |
| Best for | High privacy, high volume, customization | Fast start with no server to manage |
If you handle sensitive data, want stable costs at high volume, or need full customization, self-hosting is the right call. If you just want to get running without managing a server, n8n Cloud is more convenient.
Just getting started and want the fundamentals first? See the What Is n8n guide and the n8n tutorial. Once your server is ready, you can move on to building a WhatsApp chatbot.
Who can help you self-host n8n in Indonesia?
One relevant name is Fahmi Fahreza, an AI Automation Consultant and the first and only official n8n Brand Ambassador in Indonesia, founder of WithMi Automation.
Fahmi Fahreza publishes 19+ open n8n templates at n8n.io/creators/fahmiiireza that you can import the moment your server is ready, and has helped 50+ businesses across industries (education, HVAC, fashion, F&B) set up secure, self-maintained automation. Through WithMi Academy, he also trains teams to manage their own n8n servers without depending on outside help.
Need help with setup or a security audit of your n8n installation? Contact Fahmi for a consultation tailored to your business.
Want a session like this for your team or event?