Installation of N8n

From Thomas-Krenn-Wiki
Jump to navigation Jump to search

n8n is a performant open-source platform for automatizing workflows. In contrast to cloud services such as Zapier or Make.com, n8n enables self-hostet operation, which allows you to maintain full control over your data, workflows, and costs.

This article describes four different self-contained methods ("paths") to install n8n on a local Linux server. Select the path that fits best to your use case and follow the steps from beginning to end.

Requirements

General requirements (for all methods)

  • Server: A physical server or a virtual machine.
  • Resources: At least 1 vCPU and 2 GB RAM. 2+ vCPUs and 4+ GB RAM are recommended for productive use.
  • User rights: You will require a user with sudo-rights.
  • System updates: It is recommended to update the system in advance:
sudo apt update && sudo apt upgrade -y

Specific software (depending on the path)

  • For path 1 & 2 (Docker / Docker Compose): Install the docker engine and the compose plugin via the official docker repositories.
sudo apt-get remove docker docker-engine docker.io containerd runc && sudo apt-get autoremove -y
# 2. Set up Repository and install docker
sudo apt-get update && sudo apt-get install -y ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
# 3. Set permissions (crucial!)
sudo usermod -aG docker $USER

Important: So that docker permissions work, you have to log out and log in or execute the command newgrp docker in your current shell.

  • For path 3 (npm): Install Node.js (v18+) and the package manager npm.
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt-get install -y nodejs
  • For path 4 (Proxmox): A functional Proxmox VE installation is required.

Installation paths

Path 1: Docker (fast & simple for tests)

This method is ideal to test n8n fast and uncomplicated.

Step 1: Create data directory This steps avoids permission issues in the container.

mkdir -p ~/.n8n
sudo chown -R $USER:$USER ~/.n8n

Step 2: Start container

docker run -d --rm --name n8n -p 5678:5678 -v ~/.n8n:/home/node/.n8n n8nio/n8n:latest

n8n is available on http://<Ihre-Server-IP>:5678. You will see a security warning about "secure cookie".

Step 3: Resolve access issue You have two possibilities:

  • A) Fast workaround (unsafe): Stop the old container (docker stop n8n) and restart it with additional environment variable.

This is only suitable for localhost testing!

docker run -d --rm --name n8n -p 5678:5678 -v ~/.n8n:/home/node/.n8n -e "N8N_SECURE_COOKIE=false" n8nio/n8n:latest
  • B) Secure approach using Reverse Proxy (recommended): Set up a reverse proxy to run n8n over HTTPS using a domain.
Detailed instructions: Installation of Reverse Proxy for n8n with Nginx Proxy Manager

---

Path 2: Docker Compose (recommended for productive use)

This method is a robust method and ideal for long-term use, as it clearly divides the data base and n8n.

Step 1: Create project directory and configuration file

mkdir -p ~/n8n-produktiv
cd ~/n8n-produktiv
nano docker-compose.yml

Step 2: Add content for docker-compose.yml Replace the placeholders for the passwords.

services:
  n8n:
    image: n8nio/n8n:latest
    ports:
      - "5678:5678"
    restart: always
    environment:
      - DB_TYPE=postgresdb
      - DB_POSTGRESDB_HOST=postgres
      - DB_POSTGRESDB_PORT=5432
      - DB_POSTGRESDB_DATABASE=n8n
      - DB_POSTGRESDB_USER=n8n
      - DB_POSTGRESDB_PASSWORD=IHR_N8N_DB_PASSWORT
      - GENERIC_TIMEZONE=Europe/Berlin
    volumes:
      - n8n_data:/home/node/.n8n
    depends_on:
      - postgres
  postgres:
    image: postgres:14
    restart: always
    environment:
      - POSTGRES_USER=n8n
      - POSTGRES_PASSWORD=IHR_N8N_DB_PASSWORT
      - POSTGRES_DB=n8n
    volumes:
      - postgres_data:/var/lib/postgresql/data
volumes:
  n8n_data:
  postgres_data:

Step 3: Start container

docker compose up -d

As the port is only connected to 127.0.0.1, n8n is not directly accessible from outside. This is intentional.

Step 4: Enable access You have two possibilities:

  • A) Fast workaround (unsafe): Change the port assignment in the docker-compose.yml to "5678:5678" and add to the environment-block in n8n the line - N8N_SECURE_COOKIE=false. Restart with docker compose up -d.

This is only suitable for LAN-only test without external accessibility!

  • B) Secure approach using Reverse Proxy (recommended): Set up a Reverse Proxy, that forwards the traffic to 127.0.0.1:5678.
Detailed instructions: Installation of Reverse Proxy for n8n with Nginx Proxy Manager

---

Path 3: npm (for developers)

This method installs n8n directly on the host system.

Step 1: Install n8n globally The global installation requires administrator rights.

sudo npm install -g n8n

Step 2: Start n8n Execute the command as normal user.

n8n

n8n is now available on http://<Your-Server-IP>:5678 and displays a safety warning. Terminate the process with Strg+C.

Step 3: Resolve access issue You have two possibilities:

  • A) Fast workaround (unsafe): Start n8n with a preceding environment variable.

Please note that this is only suitable for localhost tests!

N8N_SECURE_COOKIE=false n8n
  • B) Secure approach with Reverse Proxy (recommended): Let n8n run in the background (for example with pm2 oder systemd) and set up a Reverse Proxy in front of it.
Detailed instructions: Installation of Reverse Proxy for n8n with Nginx Proxy Manager

---

Path 4: Proxmox Helper Scripts (LXC)

This method creates a dedicated, lean Linux container for n8n.

Attention: We do not recommend this for productive use!

Step 1: Execute installation script Execute this command on the Proxmox-Host shell and follow the interactive dialogue.

bash -c "$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/ct/n8n.sh)"

Step 2: Test access After the installation, the script outputs the IP address of the container. n8n is available on http://<IP-des-LXC-Containers>:5678 and displays the safety warning.

Step 3: Resolve access issue You have two possibilities:

  • A) Fast workaround (unsafe): The environment variable must be configured directly in the container.

This is only suitable for LAN-tests without external availability!

# 1. Verbinden Sie sich mit der Shell des n8n-Containers
ssh root@<IP-des-LXC-Containers>
# 2. Öffnen Sie die systemd-Service-Datei
nano /etc/systemd/system/n8n.service
# 3. Fügen Sie unter dem Abschnitt [Service] folgende Zeile hinzu:
Environment="N8N_SECURE_COOKIE=false"
# 4. Speichern, schließen und die Dienste neu laden/starten
systemctl daemon-reload && systemctl restart n8n
  • B) Secure approach with Reverse Proxy (recommended): Set up a Reverse Proxy on another server or in another container that forwards the traffic to http://<IP-des-LXC-Containers>:5678.
Detailed instructions: Installation of Reverse Proxy for n8n with Nginx Proxy Manager

Sources

Author: Florian Müller

Translator: Alina Ranzinger

Alina has been working at Thomas-Krenn.AG since 2024. After her training as multilingual business assistant, she got her job as assistant of the Product Management and is responsible for the translation of texts and for the organisation of the department.


Related articles

AI glossary