...
🚀 deploy n8n on ubuntu vps
Learn how to deploy n8n on ubuntu vps!

This article provides a step-by-step how-to guide to deploy n8n on Ubuntu VPS.

What is n8n?

n8n is an open-source, self-hostable workflow automation platform—similar to Zapier or Make.com, but far more flexible because you can run it on your own server and build fully customizable automations.

What n8n Does

n8n lets you:

  • Create automated workflows using a visual drag-and-drop editor
  • Connect APIs from hundreds of services (webhooks, CRMs, databases, email, cloud apps, etc.)
  • Run background tasks (cron jobs, scheduled scripts, daily digests)
  • Process data with built-in JavaScript functions
  • Handle complex logic, branching, loops, error handling, variables, and more
  • Host it yourself on a VPS, Docker, Kubernetes, or local machine

Why People Use n8n

  • Open-source — unlimited workflows without expensive per-task pricing
  • Extremely expandable — create your own custom nodes and integrations
  • Self-hostable — keeps your data private and under your control
  • Event-driven — ideal for incoming webhooks and API integrations
  • Code-friendly while remaining beginner-friendly

Examples of What You Can Build

  • Webhook intake → Transform JSON → Push to CRM
  • Scrape RSS feeds → Filter → Auto-post to social media
  • Database event → Send Slack/Telegram alerts
  • Cron job → Query API → Save to Google Sheets
  • Stripe order → Generate PDF invoice → Email client
  • Custom ETL pipelines between systems

How n8n is Typically Deployed

Most common setup:

  • Docker container (recommended)
  • Reverse proxy (Nginx/Caddy/Traefik)
  • HTTPS / Let’s Encrypt
  • Persistent storage volume
  • PostgreSQL (optional, for scale)

In Short

n8n = your own private Zapier, with no limits.

This setup will use:

  • Docker + Docker Compose
  • A dedicated external volume for persistence
  • Optional Traefik/HTTPS support
  • A .env file to manage environment variables

Overview

n8n is a fair-code licensed automation platform, ideal for receiving, processing, and triggering workflows via webhooks, API integrations, and more.

Prerequisites

Ensure you have Docker installed on your server or VPS:

docker --version
docker compose version

If not, install Docker and Docker Compose:

# Docker
curl -fsSL https://get.docker.com | bash

# Docker Compose v2 (plugin)
sudo apt install docker-compose-plugin -y

Launch 100% ssd ubuntu vps from $3. 19/mo!


Compare Ubuntu VPS Plans

KVM-SSD-1
KVM-SSD-8
KVM-SSD-16
KVM-SSD-32
CPU
1 Core
2 Cores
4 Cores
8 Cores
Memory
1 GB
8 GB
16 GB
32 GB
Storage
16 GB NVMe
128 GB NVMe
256 GB NVMe
512 GB NVMe
Bandwidth
1 TB
4 TB
8 TB
16 TB
Network
1 Gbps
1 Gbps
1 Gbps
1 Gbps
Delivery Time
⏱️ Instant
⏱️ Instant
⏱️ Instant
⏱️ Instant
Location
US/FR
US/FR
US/FR
US/FR
Price
$7.58*
$39.50*
$79.40*
$151.22*
KVM-SSD-1
CPU: 1 Core
Memory: 2 GB
Storage: 16 GB NVMe
1 TB
KVM-SSD-8
CPU: 2 Cores
Memory: 8 GB
Storage: 128 GB NVMe
4 TB
KVM-SSD-16
CPU: 4 Cores
Memory: 16 GB
Storage: 256 GB NVMe
8 TB
KVM-SSD-32
CPU: 8 Cores
Memory: 32 GB
Storage: 512 GB NVMe
16 TB

How to Deploy n8n on Ubuntu VPS

To deploy n8n on Ubuntu VPS, follow the steps outlined below:

  1. Create Project Directory

    mkdir -p ~/n8n-docker
    cd ~/n8n-docker
    
  2. Create .env File

    Create a .env file to store sensitive environment variables.

    nano .env
    

    Paste the following:

    # n8n config
    N8N_BASIC_AUTH_ACTIVE=true
    N8N_BASIC_AUTH_USER=admin
    N8N_BASIC_AUTH_PASSWORD=supersecurepassword
    
    # Timezone
    TZ=America/Chicago
    
    # External hostname for webhook URLs
    N8N_HOST=your.domain.com
    N8N_PORT=5678
    WEBHOOK_TUNNEL_URL=https://your.domain.com
    
    # Database (optional; use SQLite or Postgres)
    # DB_TYPE=postgresdb
    # DB_POSTGRESDB_HOST=postgres
    # DB_POSTGRESDB_PORT=5432
    # DB_POSTGRESDB_DATABASE=n8n
    # DB_POSTGRESDB_USER=n8n
    # DB_POSTGRESDB_PASSWORD=n8npassword
    

    Change credentials and N8N_HOST as needed.

  3. Create docker-compose.yml

    nano docker-compose.yml
    

    Paste the following:

    version: "3.8"
    
    services:
      n8n:
        image: n8nio/n8n:latest
        container_name: n8n
        restart: unless-stopped
        ports:
          - "5678:5678"
        environment:
          - TZ=${TZ}
          - N8N_BASIC_AUTH_ACTIVE=${N8N_BASIC_AUTH_ACTIVE}
          - N8N_BASIC_AUTH_USER=${N8N_BASIC_AUTH_USER}
          - N8N_BASIC_AUTH_PASSWORD=${N8N_BASIC_AUTH_PASSWORD}
          - N8N_HOST=${N8N_HOST}
          - N8N_PORT=${N8N_PORT}
          - WEBHOOK_TUNNEL_URL=${WEBHOOK_TUNNEL_URL}
        volumes:
          - n8n_data:/home/node/.n8n
        networks:
          - n8nnet
    
    volumes:
      n8n_data:
    
    networks:
      n8nnet:
        driver: bridge
    
  4. Enable HTTPS (Reverse Proxy via Traefik or Nginx)

    To enable HTTPS:

  5. Launch n8n

    docker compose up -d
    

    Check the logs:

    docker compose logs -f
    
  6. Access Your n8n Instance

    Open a browser and go to:

    http://your-server-ip:5678
    

    Or (if using a domain):

    https://your.domain.com
    

    Use the username/password you set in .env.

    Login to n8n instance
    Navigate to n8n using your browser to login.
  7. Webhook URLs in Production

    Make sure to use the public-facing URL for webhook calls:

    https://your.domain.com/webhook/{path}
    

    If you don’t specify N8N_HOST and WEBHOOK_TUNNEL_URL, n8n will default to local addresses (not suitable for production).

  8. Backups

    Your workflow data is saved in the Docker volume n8n_data. To back it up:

    docker run --rm --volumes-from n8n -v $(pwd):/backup ubuntu tar czf /backup/n8n-backup.tar.gz /home/node/.n8n
    

Notes

  • SQLite is default for persistence. Use Postgres for team setups or high availability.
  • n8n is stateless, so make sure environment variables are backed up.
  • You can also set up email alerts, Slack notifications, or cron-based triggers.

Launch 100% ssd ubuntu vps from $3. 19/mo!


Here’s a complete HTTPS-enabled Docker deployment of n8n using Let’s Encrypt, including a ready-to-import workflow for parsing incoming webhooks.

PART 1: HTTPS-Enabled Deployment with Let’s Encrypt (via Traefik)

This guide uses Traefik reverse proxy with automatic SSL (Let’s Encrypt), all in Docker.

Prerequisites

Project Structure

mkdir -p ~/n8n-traefik
cd ~/n8n-traefik

.env (Environment Variables)

# n8n credentials
N8N_BASIC_AUTH_ACTIVE=true
N8N_BASIC_AUTH_USER=admin
N8N_BASIC_AUTH_PASSWORD=SuperSecurePassword123

# Domain
DOMAIN=n8n.example.com
EMAIL=your@email.com

docker-compose.yml

version: '3.8'

services:
  traefik:
    image: traefik:v2.11
    container_name: traefik
    restart: unless-stopped
    command:
      - "--entrypoints.web.address=:80"
      - "--entrypoints.websecure.address=:443"
      - "--providers.docker=true"
      - "--providers.docker.exposedbydefault=false"
      - "--certificatesresolvers.le.acme.email=${EMAIL}"
      - "--certificatesresolvers.le.acme.storage=/letsencrypt/acme.json"
      - "--certificatesresolvers.le.acme.tlschallenge=true"
      - "--api.dashboard=true"
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - "./letsencrypt:/letsencrypt"
      - "/var/run/docker.sock:/var/run/docker.sock:ro"
    networks:
      - n8nnet

  n8n:
    image: n8nio/n8n:latest
    container_name: n8n
    restart: unless-stopped
    environment:
      - N8N_BASIC_AUTH_ACTIVE=${N8N_BASIC_AUTH_ACTIVE}
      - N8N_BASIC_AUTH_USER=${N8N_BASIC_AUTH_USER}
      - N8N_BASIC_AUTH_PASSWORD=${N8N_BASIC_AUTH_PASSWORD}
      - N8N_HOST=${DOMAIN}
      - N8N_PORT=443
      - WEBHOOK_URL=https://${DOMAIN}
      - VUE_APP_URL_BASE_API=https://${DOMAIN}
      - TZ=America/Chicago
    volumes:
      - n8n_data:/home/node/.n8n
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.n8n.rule=Host(`${DOMAIN}`)"
      - "traefik.http.routers.n8n.entrypoints=websecure"
      - "traefik.http.routers.n8n.tls.certresolver=le"
      - "traefik.http.services.n8n.loadbalancer.server.port=5678"
    networks:
      - n8nnet

volumes:
  n8n_data:

networks:
  n8nnet:
    driver: bridge

Launch the Stack

docker compose up -d

Your n8n instance should now be accessible at:

https://n8n.example.com

Login with your username/password from .env.

PART 2: Ready-to-Import n8n Webhook Workflow

This workflow listens for a POST webhook with JSON input, parses the data, and responds with a confirmation.

Import JSON

Here’s a minimal n8n workflow you can import:

Click to Expand JSON

{
  "name": "Webhook Listener",
  "nodes": [
    {
      "parameters": {
        "path": "incoming-webhook",
        "options": {}
      },
      "id": "WebhookTrigger",
      "name": "Webhook Trigger",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [240, 300],
      "webhookId": "custom-id"
    },
    {
      "parameters": {
        "functionCode": "return [{ json: {\n  message: \"Webhook received!\",\n  input: $json\n} }];"
      },
      "id": "Function",
      "name": "Respond",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [480, 300]
    }
  ],
  "connections": {
    "Webhook Trigger": {
      "main": [
        [
          {
            "node": "Respond",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false
}

How to Import:

  1. Log in to https://n8n.example.com
  2. Go to Workflows > Import
  3. Paste the JSON above or upload as .json
  4. Activate the workflow

Now test it:

curl -X POST https://n8n.example.com/webhook/incoming-webhook \
  -H "Content-Type: application/json" \
  -d '{"name":"Larry","project":"Webhook Parser"}'

Response:

{
  "message": "Webhook received!",
  "input": {
    "name": "Larry",
    "project": "Webhook Parser"
  }
}

Launch 100% ssd ubuntu vps from $3. 19/mo!

Conclusion

You now know how to deploy n8n on Ubuntu VPS.

Avatar of editorial staff

Editorial Staff

Rad Web Hosting is a leading provider of web hosting, Cloud VPS, and Dedicated Servers in Dallas, TX.
lg