# n8n – Installation and Setup

n8n – Installation and Setup – Self-hosting guide on your NexoraHost server.

n8n is a free, open-source workflow automation tool with a visual interface. It connects apps and services with each other – similar to Zapier or Make, but on your own server. With n8n on your NexoraHost VPS or root server, you save expensive subscription fees and retain full control over your data.

**Note:** Detailed subpages on first workflows and complex automations can be found in the left navigation.

## Why self-host n8n?

    - No monthly costs – the self-hosted plan is completely free and unlimited
- Unlimited workflows, users and executions
- Full control over your data – ideal for GDPR-compliant automations
- Over 400 integrations: Google, Slack, Discord, Telegram, databases, email and much more
- Extremely extendable through custom nodes and custom JavaScript/TypeScript code

## Requirements

    - A VPS or root server with Ubuntu 22.04/24.04 (other Linux distributions work similarly)
- SSH access with root privileges
- At least 2 GB RAM (4 GB recommended for complex workflows)
- Your own domain with SSL (strongly recommended for secure access)
- Docker and Docker-Compose (we'll install them in Step 1)

## Step 1: Install Docker

Docker is the cleanest method, as all dependencies are isolated in the container:

`# Install Docker (Ubuntu/Debian)
sudo apt update
sudo apt install docker.io docker-compose -y

# Enable Docker on system startup
sudo systemctl enable --now docker

# Add current user to the Docker group (saves sudo on every command)
sudo usermod -aG docker $USER`
After adding to the group, log out and log back in for the change to take effect.

## Step 2: Prepare folder structure

`# Main directory for n8n
mkdir -p ~/n8n && cd ~/n8n

# Subfolders for data and backups
mkdir -p {n8n_data,backup}`

## Step 3: Start n8n with Docker-Compose

Create the docker-compose.yml:

`nano ~/n8n/docker-compose.yml`
Add the following content:

`version: '3.8'
services:
  n8n:
    image: n8nio/n8n:latest
    container_name: n8n
    environment:
      - N8N_BASIC_AUTH_ACTIVE=true
      - N8N_BASIC_AUTH_USER=admin
      - N8N_BASIC_AUTH_PASSWORD=your-secure-password
      - NODE_ENV=production
      - N8N_HOST=n8n.your-domain.com
      - N8N_PORT=5678
      - N8N_PROTOCOL=https
      - WEBHOOK_URL=https://n8n.your-domain.com
      - N8N_ENCRYPTION_KEY=your-random-generated-key
      - N8N_USER_MANAGEMENT_DISABLED=false
      - N8N_DIAGNOSTICS_ENABLED=false
      - GENERIC_TIMEZONE=Europe/Berlin
      - TZ=Europe/Berlin
    ports:
      - 5678:5678
    volumes:
      - ./n8n_data:/home/node/.n8n
    restart: unless-stopped`

**Important environment variables explained:**

    - **N8N_BASIC_AUTH_ACTIVE / _USER / _PASSWORD:** Enables login protection. Without these settings, anyone can access your n8n
- **N8N_HOST / N8N_PROTOCOL:** Your domain – important for correct redirects
- **WEBHOOK_URL:** The base URL for incoming webhooks. Without this, webhooks from external services won't work
- **N8N_ENCRYPTION_KEY:** Encrypts credentials in the database. Generate a random key (e.g. with `openssl rand -hex 32`)
- **N8N_USER_MANAGEMENT_DISABLED:** false = multi-user mode enabled (everyone needs an account)

Start the container:

`cd ~/n8n
docker-compose up -d`

## Step 4: Set up n8n in the browser

    - Open `http://your-server-ip:5678` in your browser
- Log in with the credentials set in docker-compose.yml (admin / your-secure-password)
- The setup wizard guides you through the first steps:
        
            - Confirm your email address (optional, but recommended for notifications)
- Choose whether to share diagnostic data (recommended: No)

    

## Step 5: Create your first workflow

A workflow is a chain of actions. Here's a simple example – an email notification when a webhook is called:

    - Click **New Workflow**
- Add a **Webhook Node** (from the "Trigger" list)
- Configure the webhook:
        
            - **HTTP Method:** POST
- **Path:** /my-first-webhook
- **Response Mode:** Last Node

    
- Add an **Email Node** (from "Communication")
- Configure the email:
        
            - **To:** your@email.com
- **Subject:** New Webhook Call!
- **Text:** The webhook was called at {{ $json.timestamp }}

    
- Connect the nodes via drag-and-drop
- Click **Execute Workflow** to test
- After successful test: Toggle the **Active** switch in the top right

## Step 6: Secure external access with SSL

To securely access n8n from outside and for webhooks to work, you need a reverse proxy with SSL:

`# Install Nginx
sudo apt install nginx certbot python3-certbot-nginx -y

# Create Nginx configuration
sudo nano /etc/nginx/sites-available/n8n`
`server {
    listen 80;
    server_name n8n.your-domain.com;

    location / {
        proxy_pass http://localhost:5678;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_read_timeout 120s;
    }
}`
`# Enable the site
sudo ln -s /etc/nginx/sites-available/n8n /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl restart nginx

# Get SSL certificate
sudo certbot --nginx -d n8n.your-domain.com`

## Step 7: Update n8n

n8n regularly receives updates with new nodes and features. Here's how to update safely:

`# Create backup
cd ~/n8n
tar -czf backup/n8n_$(date +%Y%m%d_%H%M).tar.gz n8n_data

# Pull latest version and restart container
docker-compose pull
docker-compose up -d

# Clean up old Docker images
docker image prune -f`

## Step 8: Important settings for production

### Configure email for notifications

    - Go to **Settings → Email**
- Enter your SMTP details (e.g. from your NexoraHost webspace)
- Test the connection with "Send Test Email"

### Backup your workflows

In addition to automatic file backups, you can also export workflows manually:

    - Open a workflow
- Click the three dots in the top right → **Download**
- The JSON file contains the complete workflow and can be imported at any time

### User management

If `N8N_USER_MANAGEMENT_DISABLED=false` is set, you can invite additional users:

    - Go to **Settings → Users**
- Click **Invite User**
- Enter an email address and select the role (Member or Admin)
- The user receives an invitation email

## Common problems and solutions

**Webhooks not working from outside:**

    - Check if the WEBHOOK_URL environment variable is set correctly
- Check if the reverse proxy is running correctly: `sudo nginx -t`
- Make sure port 443 is open in the firewall

**n8n won't start or crashes:**

    - Check the logs: `docker logs n8n`
- Most common cause: N8N_ENCRYPTION_KEY was changed afterwards – all saved credentials are lost
- If the key is lost: Stop container, search for old key in logs or reset database

**Workflow runs slowly:**

    - Check server resources with `htop`
- Complex workflows with many HTTP requests can take minutes – increase timeout with `EXECUTIONS_TIMEOUT`
- Consider upgrading to a larger VPS with more RAM

## Useful tips for getting started

    - **Use templates:** n8n offers hundreds of ready-made workflow templates. Click **Templates** in the left sidebar
- **Cron trigger:** With the "Schedule" node you can run workflows on a schedule – e.g. send a report daily at 8 AM
- **Error handling:** Each node has an "Error" output. Connect it to a notification node to be informed about errors
- **Sub-workflows:** Outsource recurring logic into separate workflows and call them via the "Execute Workflow" node

*Detailed guides on individual nodes, API integrations and complex automations can be found in the articles in the left navigation.*
