Fahmi Fahreza

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:

WorkloadvCPURAMStorageNotes
Testing / personal1-22 GB20 GB SSDFine for a few light workflows
Small business22-4 GB40 GB SSDIdeal for WhatsApp + CRM + light AI
Production / AI agent44-8 GB60-100 GB SSDMany 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.

  1. Log into the VPS via SSH and update the system.

    ssh root@YOUR_VPS_IP
    apt update && apt upgrade -y
    
  2. Install Docker and the Docker Compose plugin.

    curl -fsSL https://get.docker.com | sh
    apt install docker-compose-plugin -y
    

    Verify with docker --version and docker compose version.

  3. Point your domain to the server. In your domain's DNS panel, create an A record for n8n.yourdomain.com pointing to your VPS public IP. Wait for DNS propagation (usually a few minutes to an hour).

  4. Create a project folder and config file.

    mkdir ~/n8n && cd ~/n8n
    nano docker-compose.yml
    
  5. Fill in docker-compose.yml with 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:
    
  6. Create a Caddyfile in the same folder for the reverse proxy + automatic HTTPS:

    n8n.yourdomain.com {
        reverse_proxy n8n:5678
    }
    
  7. Start n8n.

    docker compose up -d
    

    Caddy will fetch the SSL certificate automatically. Open https://n8n.yourdomain.com in your browser and create your first owner account.

  8. 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_data volume 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:

AspectSelf-host (VPS + Docker)n8n Cloud
Data controlFull (your own server)Managed by n8n
CostStable, starts at a few dollars/monthSubscription per execution/seat
MaintenanceYour responsibilityAutomatic
Best forHigh privacy, high volume, customizationFast 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?