How to Install n8n for Workflow Automation

n8n is a self-hosted workflow automation tool — connecting apps and APIs through a visual editor, similar to Zapier or Make, but running entirely on your own infrastructure.

Prerequisites

  • Docker Engine and Docker Compose installed
  • A domain name (recommended for production use with webhooks)

Step 1 — Create a Project Directory

mkdir ~/n8n && cd ~/n8n

Step 2 — Create docker-compose.yml

services:
  n8n:
    image: docker.n8n.io/n8nio/n8n
    restart: unless-stopped
    ports:
      - "5678:5678"
    environment:
      - N8N_HOST=n8n.yourdomain.com
      - N8N_PROTOCOL=https
      - WEBHOOK_URL=https://n8n.yourdomain.com/
      - GENERIC_TIMEZONE=UTC
    volumes:
      - n8n_data:/home/node/.n8n

volumes:
  n8n_data:

Step 3 — Start n8n

docker compose up -d

Step 4 — Add HTTPS via Nginx Proxy Manager

Route n8n.yourdomain.com to port 5678 — see How to Install Nginx Proxy Manager with Docker. HTTPS is important here since n8n handles webhook URLs and often credentials for connected services.

Step 5 — Access n8n

https://n8n.yourdomain.com

Create your owner account on first visit.

Creating Your First Workflow

  1. Click Add workflow
  2. Add a trigger node (schedule, webhook, or manual trigger)
  3. Add action nodes connecting to your desired services (email, Slack, database, HTTP requests)
  4. Test and activate the workflow

Using a Persistent Database (Recommended for Production)

By default n8n uses SQLite; for production workloads with many workflows, configure PostgreSQL instead:

services:
  postgres:
    image: postgres:16
    restart: unless-stopped
    environment:
      POSTGRES_DB: n8n
      POSTGRES_USER: n8n
      POSTGRES_PASSWORD: ${DB_PASSWORD}
    volumes:
      - postgres_data:/var/lib/postgresql/data

  n8n:
    image: docker.n8n.io/n8nio/n8n
    restart: unless-stopped
    environment:
      - DB_TYPE=postgresdb
      - DB_POSTGRESDB_HOST=postgres
      - DB_POSTGRESDB_DATABASE=n8n
      - DB_POSTGRESDB_USER=n8n
      - DB_POSTGRESDB_PASSWORD=${DB_PASSWORD}
    depends_on:
      - postgres
    volumes:
      - n8n_data:/home/node/.n8n

volumes:
  postgres_data:
  n8n_data:

Backing Up n8n

docker exec n8n-postgres-1 pg_dump -U n8n n8n > n8n-db-backup.sql
docker run --rm -v n8n_n8n_data:/data -v $(pwd):/backup alpine tar czf /backup/n8n-data-backup.tar.gz /data

Common Errors

Webhooks don't trigger — confirm WEBHOOK_URL matches your actual public HTTPS domain exactly, including trailing slash conventions.

n8n loses workflows after container restart — confirm the volume is correctly configured and persisting data outside the container.

Best Practices

  • Use PostgreSQL instead of default SQLite for any production workload with meaningful workflow volume
  • Always run behind HTTPS given the sensitive nature of connected service credentials
  • Back up both the database and the .n8n data volume regularly

Continue Reading

Browse more articles in Popular Self-Hosted Applications.

  • n8n, workflow automation, zapier alternative, self hosted automation
  • 0 Kunder som kunne bruge dette svar
Hjalp dette svar dig?

Relaterede artikler

How to Install Nextcloud on a VPS with Docker

Nextcloud is a self-hosted file sync, sharing, and collaboration platform — a...

How to Install GitLab CE on a VPS

GitLab Community Edition is a full-featured, self-hosted DevOps platform — Git repository...

How to Install Ghost CMS on a VPS

Ghost is a modern, fast, purpose-built platform for blogging and newsletters — a lighter,...

How to Set Up a Minecraft Server on a VPS

Running your own Minecraft server gives you full control over mods, plugins, and world settings....

How to Install Gitea (Lightweight Git Server)

Gitea is a lightweight, self-hosted Git service — a much lower-resource alternative to...