Library
N8N Foundation · Chapter 2 of 10
Chapter 02

Installing & Configuring
n8n

Ten ways to run n8n — from Desktop double-click to a hardened Ubuntu VPS behind Nginx and SSL — and the settings that separate a hobby install from a production one.

InstallDockerRailwayVPSNginxSSL
A Handbook For Builders
Installing & Configuring
n8n
Chapter 02
The Claude Code Handbook

There is no single right way to run n8n. The Desktop app is fine for a weekend hack. A $5 Hetzner VPS with Docker Compose runs an entire agency's automations. This chapter walks every path — you will pick one, install it, and end with a workflow live on the internet.

Section 1

1. Deployment Options at a Glance

diagramclaude-code
Setup             Cost      Difficulty   Best for
n8n Cloud         $$$       ★           No-ops, small teams
Desktop App       free      ★           Learning on your laptop
npm (local)       free      ★★          Developer machine
Docker            free      ★★          Any Linux/Mac
Docker Compose    free      ★★★         Production w/ Postgres
Railway           $         ★           One-click cloud
Render            $         ★           One-click cloud
DO / Hetzner VPS  $         ★★★         Full control
Section 2

2. n8n Cloud

  1. Sign up at n8n.io/cloud.
  2. Pick a plan (Starter enough for 5 active workflows).
  3. Your instance is at your-name.app.n8n.cloud. No install needed.
n8n Cloud
Screenshot placeholder
n8n Cloud onboarding — instance URL, first login, empty canvas.
Figure — n8n Cloud onboarding — instance URL, first login, empty canvas.
Section 3

3. Desktop App

Download from n8n.io/download. Runs on Mac / Windows / Linux. Uses SQLite by default. Great for learning; not for production.

Section 4

4. Local via npm

bashclaude-code
# Requires Node.js 20 LTS
npm install -g n8n
n8n start
# → http://localhost:5678
Section 5

5. Docker (single container)

bashclaude-code
docker volume create n8n_data

docker run -d --restart unless-stopped \
  --name n8n \
  -p 5678:5678 \
  -e N8N_HOST="n8n.example.com" \
  -e N8N_PROTOCOL=https \
  -e WEBHOOK_URL="https://n8n.example.com/" \
  -e N8N_ENCRYPTION_KEY="$(openssl rand -hex 32)" \
  -v n8n_data:/home/node/.n8n \
  n8nio/n8n:latest
Section 6

6. Docker Compose + Postgres (production)

yamlclaude-code
# docker-compose.yml
services:
  postgres:
    image: postgres:16
    restart: unless-stopped
    environment:
      POSTGRES_USER: n8n
      POSTGRES_PASSWORD: ${DB_PASSWORD}
      POSTGRES_DB: n8n
    volumes: [db:/var/lib/postgresql/data]

  n8n:
    image: n8nio/n8n:latest
    restart: unless-stopped
    depends_on: [postgres]
    ports: ["127.0.0.1:5678:5678"]
    environment:
      DB_TYPE: postgresdb
      DB_POSTGRESDB_HOST: postgres
      DB_POSTGRESDB_USER: n8n
      DB_POSTGRESDB_PASSWORD: ${DB_PASSWORD}
      N8N_ENCRYPTION_KEY: ${N8N_ENCRYPTION_KEY}
      N8N_HOST: n8n.example.com
      N8N_PROTOCOL: https
      WEBHOOK_URL: https://n8n.example.com/
    volumes: [data:/home/node/.n8n]

volumes: { db: {}, data: {} }
Section 7

7. Railway

  1. New Project → Deploy from Docker image → n8nio/n8n.
  2. Add a Postgres plugin. Copy its variables into the n8n service.
  3. Add a public domain. Set WEBHOOK_URL to that domain.
Section 8

8. Render

New Web Service → Docker → image n8nio/n8n → attach a Render Postgres instance. Same env vars as Compose.

Section 9

9. DigitalOcean / Hetzner VPS

bashclaude-code
# Ubuntu 24.04, 2 GB droplet is enough for 50 workflows.
adduser n8n && usermod -aG sudo n8n
apt update && apt install -y docker.io docker-compose-plugin ufw
ufw allow OpenSSH && ufw allow 80 && ufw allow 443 && ufw enable
# clone your compose file, then:
docker compose up -d
Section 10

10. Ubuntu + Nginx + SSL

nginxclaude-code
# /etc/nginx/sites-available/n8n
server {
  server_name n8n.example.com;
  location / {
    proxy_pass http://127.0.0.1:5678;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_set_header Host $host;
    proxy_read_timeout 3600s;
  }
}
bashclaude-code
sudo ln -s /etc/nginx/sites-available/n8n /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl reload nginx
sudo certbot --nginx -d n8n.example.com
Section 11

11. Environment Variables that Matter

  • N8N_HOST, N8N_PROTOCOL, WEBHOOK_URL — must match your public URL.
  • N8N_ENCRYPTION_KEY — 32-byte hex. Lose this and every credential becomes garbage.
  • N8N_BASIC_AUTH_ACTIVE, N8N_BASIC_AUTH_USER/PASSWORD — first-layer lock.
  • EXECUTIONS_DATA_PRUNE=true + EXECUTIONS_DATA_MAX_AGE=336 — keep the DB small.
  • N8N_LOG_LEVEL=infodebug only while debugging; it is verbose.
Section 12

12. The Encryption Key

Section 13

13. Credentials

Under Settings → Credentials, add each service once (OpenAI, Google, Slack, etc.). Any node can pick a saved credential from a dropdown. Never paste tokens into node parameters.

Section 14

14. Users & Projects

The free version supports a single-owner + members model; paid plans add multi-project workspaces. Give each team member their own login — you get a full audit trail per user.

Section 15

15. Folders & Tags

Use tags (#client-acme, #prod, #draft) to filter. Move stable workflows into a "Production" folder.

Section 16

16. Workflow Settings

  • Save successful executions: off in prod for hot workflows.
  • Save data errors: always on.
  • Error Workflow: point every prod workflow at a shared error handler.
  • Timezone: set explicitly; do not trust the server default.
Section 17

17. Community Nodes

bashclaude-code
# Inside the container
npm install n8n-nodes-<package>
# Then Settings → Community Nodes → install by npm name.
Section 18

18. Templates

Import a workflow from n8n.io/workflows with one click. Great starting points; always audit credentials and URLs before running.

Section 19

19. Backup & Restore

bashclaude-code
# Nightly cron on the VPS
docker exec postgres pg_dump -U n8n n8n | gzip > /backups/n8n-$(date +%F).sql.gz
# Keep the encryption key alongside — restore is meaningless without it.
Section 20

20. Version Control

n8n workflows are JSON. Export from the three-dot menu → commit to a Git repo. Paid plans expose native GitHub sync. Either way, treat workflows like code: PR review, branches, tags.