n8n-self-host
Dockerを使ったn8nのインストール、本番環境での設定、環境変数の調整、ワーカーによる拡張、バックアップ、リストア、CLI/API管理、監視、トラブルシューティング、PostgreSQL連携、リバースプロキシ導入など、n8nの自己ホスト環境を構築・運用・管理するSkill。
📜 元の英語説明(参考)
Self-host, configure, scale, and manage n8n instances. Use when a user asks to install n8n with Docker, set up n8n in production, configure n8n environment variables, scale n8n with workers, back up n8n workflows, restore n8n data, manage n8n via CLI or REST API, monitor n8n, troubleshoot n8n issues, set up n8n with PostgreSQL, or deploy n8n with a reverse proxy. For designing n8n workflows and nodes, see n8n-workflow.
🇯🇵 日本人クリエイター向け解説
Dockerを使ったn8nのインストール、本番環境での設定、環境変数の調整、ワーカーによる拡張、バックアップ、リストア、CLI/API管理、監視、トラブルシューティング、PostgreSQL連携、リバースプロキシ導入など、n8nの自己ホスト環境を構築・運用・管理するSkill。
※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o n8n-self-host.zip https://jpskill.com/download/15151.zip && unzip -o n8n-self-host.zip && rm n8n-self-host.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/15151.zip -OutFile "$d\n8n-self-host.zip"; Expand-Archive "$d\n8n-self-host.zip" -DestinationPath $d -Force; ri "$d\n8n-self-host.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
n8n-self-host.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
n8n-self-hostフォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-18
- 取得日時
- 2026-05-18
- 同梱ファイル
- 1
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
n8n Self-Host
概要
セルフホストされた n8n インスタンスのインストール、構成、スケーリング、および運用を行います。Docker Compose を使用した本番環境のセットアップ、CLI 管理、REST API の自動化、Redis ワーカーによるキューモードでのスケーリング、バックアップ/リストア、監視、およびトラブルシューティングについて説明します。n8n ワークフローの構築およびノードの構成については、n8n-workflow skill を参照してください。
手順
タスク A: 本番環境向け Docker Compose セットアップ
PostgreSQL (デフォルトの SQLite よりも推奨) を使用した基本的なセットアップ:
# docker-compose.yml
services:
postgres:
image: postgres:16
restart: always
environment:
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB}
volumes:
- db_storage:/var/lib/postgresql/data
healthcheck:
test: ['CMD-SHELL', 'pg_isready -h localhost -U ${POSTGRES_USER} -d ${POSTGRES_DB}']
interval: 5s
timeout: 5s
retries: 10
n8n:
image: docker.n8n.io/n8nio/n8n
restart: always
ports:
- "5678:5678"
environment:
- DB_TYPE=postgresdb
- DB_POSTGRESDB_HOST=postgres
- DB_POSTGRESDB_PORT=5432
- DB_POSTGRESDB_DATABASE=${POSTGRES_DB}
- DB_POSTGRESDB_USER=${POSTGRES_USER}
- DB_POSTGRESDB_PASSWORD=${POSTGRES_PASSWORD}
- N8N_ENCRYPTION_KEY=${ENCRYPTION_KEY}
- WEBHOOK_URL=${WEBHOOK_URL}
- GENERIC_TIMEZONE=${GENERIC_TIMEZONE:-UTC}
- N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true
- N8N_RUNNERS_ENABLED=true
volumes:
- n8n_storage:/home/node/.n8n
depends_on:
postgres:
condition: service_healthy
volumes:
db_storage:
n8n_storage:
POSTGRES_USER、POSTGRES_PASSWORD、POSTGRES_DB、ENCRYPTION_KEY ( openssl rand -hex 24 で生成)、WEBHOOK_URL、および GENERIC_TIMEZONE と共に .env ファイルを作成します。docker compose up -d で起動します。
タスク B: キューモードでのスケーリング (Redis + ワーカー)
大量のワークロードの場合は、Redis とワーカープロセスを追加します。
# docker-compose.yml に追加
x-n8n-shared: &n8n-shared
image: docker.n8n.io/n8nio/n8n
restart: always
environment:
- DB_TYPE=postgresdb
- DB_POSTGRESDB_HOST=postgres
- DB_POSTGRESDB_DATABASE=${POSTGRES_DB}
- DB_POSTGRESDB_USER=${POSTGRES_USER}
- DB_POSTGRESDB_PASSWORD=${POSTGRES_PASSWORD}
- EXECUTIONS_MODE=queue
- QUEUE_BULL_REDIS_HOST=redis
- QUEUE_HEALTH_CHECK_ACTIVE=true
- N8N_ENCRYPTION_KEY=${ENCRYPTION_KEY}
volumes:
- n8n_storage:/home/node/.n8n
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
services:
redis:
image: redis:7-alpine
restart: always
volumes:
- redis_storage:/data
healthcheck:
test: ['CMD', 'redis-cli', 'ping']
interval: 5s
n8n:
<<: *n8n-shared
ports:
- "5678:5678"
n8n-worker:
<<: *n8n-shared
command: worker
# スケールするには: docker compose up -d --scale n8n-worker=3
タスク C: CLI 管理
Docker 内で CLI コマンドを実行します: docker exec -u node -it n8n n8n <command>。
# ワークフローのエクスポート/インポート
n8n export:workflow --backup --output=backups/
n8n export:workflow --id=<ID> --output=workflow.json
n8n import:workflow --input=workflow.json
n8n import:workflow --separate --input=backups/
# クレデンシャルのエクスポート/インポート (--decrypted はインスタンス間の移行用)
n8n export:credentials --backup --output=backups/
n8n export:credentials --all --decrypted --output=creds.json
n8n import:credentials --input=creds.json
# データベース全体のバックアップ/リストア
n8n export:entities --outputDir=./backup --includeExecutionHistoryDataTables=true
n8n import:entities --inputDir=./backup --truncateTables=true
# ID でワークフローを実行
n8n execute --id=<ID>
# ワークフローのアクティブ化/非アクティブ化
n8n update:workflow --id=<ID> --active=true
n8n update:workflow --all --active=false
# ユーザー管理
n8n user-management:reset # セットアップ状態にリセット (パスワードを忘れた場合)
n8n mfa:disable --email=user@x.com # ロックアウトされたユーザーの MFA を無効化
# セキュリティ監査
n8n audit
# データベース移行のロールバック
n8n db:revert
タスク D: REST API の自動化
/api/v1/docs で API を有効にします。X-N8N-API-KEY ヘッダーで認証します。
# すべてのワークフローをリスト表示
curl -s -H "X-N8N-API-KEY: $N8N_API_KEY" http://localhost:5678/api/v1/workflows | jq '.data[].name'
# ワークフローをアクティブ化
curl -X POST -H "X-N8N-API-KEY: $N8N_API_KEY" http://localhost:5678/api/v1/workflows/<ID>/activate
# ワークフローを非アクティブ化
curl -X POST -H "X-N8N-API-KEY: $N8N_API_KEY" http://localhost:5678/api/v1/workflows/<ID>/deactivate
# 失敗した実行を再試行
curl -X POST -H "X-N8N-API-KEY: $N8N_API_KEY" http://localhost:5678/api/v1/executions/<ID>/retry
# 失敗した実行をリスト表示
curl -s -H "X-N8N-API-KEY: $N8N_API_KEY" "http://localhost:5678/api/v1/executions?status=error" | jq '.data[] | {id, workflowId, status}'
# 変数を作成
curl -X POST -H "X-N8N-API-KEY: $N8N_API_KEY" -H "Content-Type: application/json" \
-d '{"key":"ENV","value":"production"}' http://localhost:5678/api/v1/variables
タスク E: 主要な環境変数
| 変数 | デフォルト | 目的 |
|---|---|---|
DB_TYPE |
sqlite |
sqlite または postgresdb |
N8N_ENCRYPTION_KEY |
ランダム | クレデンシャルの暗号化 (再起動後も保持) |
WEBHOOK_URL |
自動 | リバースプロキシの背後にある Webhook のパブリック URL |
EXECUTIONS_MODE |
regular |
regular または queue (スケーリング用) |
EXECUTIONS_DATA_PRUNE |
true |
古い実行データを自動的に削除 |
EXECUTIONS_DATA_MAX_AGE |
336 |
実行データの最大保存期間 (時間単位) |
N8N_METRICS |
false |
Prometheus /metrics エンドポイントを有効化 |
N8N_LOG_LEVEL |
info |
error、warn、info、debug |
N8N_LOG_OUTPUT |
console |
console、file (カンマ区切り) |
N8N_CONCURRENCY_PRODUCTION_LIMIT |
-1 |
本番環境での同時実行数の上限 |
N8N_RUNNERS_ENABLED |
false |
Code ノードのタスクランナーを有効化 |
GENERIC_TIMEZONE |
America/New_York |
タイムゾーン |
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
n8n Self-Host
Overview
Install, configure, scale, and operate self-hosted n8n instances. Covers Docker Compose production setups, CLI administration, REST API automation, queue-mode scaling with Redis workers, backup/restore, monitoring, and troubleshooting. For building n8n workflows and configuring nodes, see the n8n-workflow skill.
Instructions
Task A: Production Docker Compose Setup
Basic setup with PostgreSQL (recommended over default SQLite):
# docker-compose.yml
services:
postgres:
image: postgres:16
restart: always
environment:
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB}
volumes:
- db_storage:/var/lib/postgresql/data
healthcheck:
test: ['CMD-SHELL', 'pg_isready -h localhost -U ${POSTGRES_USER} -d ${POSTGRES_DB}']
interval: 5s
timeout: 5s
retries: 10
n8n:
image: docker.n8n.io/n8nio/n8n
restart: always
ports:
- "5678:5678"
environment:
- DB_TYPE=postgresdb
- DB_POSTGRESDB_HOST=postgres
- DB_POSTGRESDB_PORT=5432
- DB_POSTGRESDB_DATABASE=${POSTGRES_DB}
- DB_POSTGRESDB_USER=${POSTGRES_USER}
- DB_POSTGRESDB_PASSWORD=${POSTGRES_PASSWORD}
- N8N_ENCRYPTION_KEY=${ENCRYPTION_KEY}
- WEBHOOK_URL=${WEBHOOK_URL}
- GENERIC_TIMEZONE=${GENERIC_TIMEZONE:-UTC}
- N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true
- N8N_RUNNERS_ENABLED=true
volumes:
- n8n_storage:/home/node/.n8n
depends_on:
postgres:
condition: service_healthy
volumes:
db_storage:
n8n_storage:
Create a .env alongside with POSTGRES_USER, POSTGRES_PASSWORD, POSTGRES_DB, ENCRYPTION_KEY (generate with openssl rand -hex 24), WEBHOOK_URL, and GENERIC_TIMEZONE. Start with docker compose up -d.
Task B: Scale with Queue Mode (Redis + Workers)
For high-volume workloads, add Redis and worker processes:
# Add to docker-compose.yml
x-n8n-shared: &n8n-shared
image: docker.n8n.io/n8nio/n8n
restart: always
environment:
- DB_TYPE=postgresdb
- DB_POSTGRESDB_HOST=postgres
- DB_POSTGRESDB_DATABASE=${POSTGRES_DB}
- DB_POSTGRESDB_USER=${POSTGRES_USER}
- DB_POSTGRESDB_PASSWORD=${POSTGRES_PASSWORD}
- EXECUTIONS_MODE=queue
- QUEUE_BULL_REDIS_HOST=redis
- QUEUE_HEALTH_CHECK_ACTIVE=true
- N8N_ENCRYPTION_KEY=${ENCRYPTION_KEY}
volumes:
- n8n_storage:/home/node/.n8n
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
services:
redis:
image: redis:7-alpine
restart: always
volumes:
- redis_storage:/data
healthcheck:
test: ['CMD', 'redis-cli', 'ping']
interval: 5s
n8n:
<<: *n8n-shared
ports:
- "5678:5678"
n8n-worker:
<<: *n8n-shared
command: worker
# Scale with: docker compose up -d --scale n8n-worker=3
Task C: CLI Administration
Run CLI commands inside Docker: docker exec -u node -it n8n n8n <command>.
# Export/import workflows
n8n export:workflow --backup --output=backups/
n8n export:workflow --id=<ID> --output=workflow.json
n8n import:workflow --input=workflow.json
n8n import:workflow --separate --input=backups/
# Export/import credentials (--decrypted for cross-instance migration)
n8n export:credentials --backup --output=backups/
n8n export:credentials --all --decrypted --output=creds.json
n8n import:credentials --input=creds.json
# Full database backup/restore
n8n export:entities --outputDir=./backup --includeExecutionHistoryDataTables=true
n8n import:entities --inputDir=./backup --truncateTables=true
# Execute a workflow by ID
n8n execute --id=<ID>
# Activate/deactivate workflows
n8n update:workflow --id=<ID> --active=true
n8n update:workflow --all --active=false
# User management
n8n user-management:reset # Reset to setup state (forgot password)
n8n mfa:disable --email=user@x.com # Disable MFA for locked-out user
# Security audit
n8n audit
# Database migration rollback
n8n db:revert
Task D: REST API Automation
Enable the API at /api/v1/docs. Authenticate with X-N8N-API-KEY header.
# List all workflows
curl -s -H "X-N8N-API-KEY: $N8N_API_KEY" http://localhost:5678/api/v1/workflows | jq '.data[].name'
# Activate a workflow
curl -X POST -H "X-N8N-API-KEY: $N8N_API_KEY" http://localhost:5678/api/v1/workflows/<ID>/activate
# Deactivate a workflow
curl -X POST -H "X-N8N-API-KEY: $N8N_API_KEY" http://localhost:5678/api/v1/workflows/<ID>/deactivate
# Retry a failed execution
curl -X POST -H "X-N8N-API-KEY: $N8N_API_KEY" http://localhost:5678/api/v1/executions/<ID>/retry
# List failed executions
curl -s -H "X-N8N-API-KEY: $N8N_API_KEY" "http://localhost:5678/api/v1/executions?status=error" | jq '.data[] | {id, workflowId, status}'
# Create a variable
curl -X POST -H "X-N8N-API-KEY: $N8N_API_KEY" -H "Content-Type: application/json" \
-d '{"key":"ENV","value":"production"}' http://localhost:5678/api/v1/variables
Task E: Key Environment Variables
| Variable | Default | Purpose |
|---|---|---|
DB_TYPE |
sqlite |
sqlite or postgresdb |
N8N_ENCRYPTION_KEY |
random | Credential encryption (preserve across restarts) |
WEBHOOK_URL |
auto | Public URL for webhooks behind reverse proxy |
EXECUTIONS_MODE |
regular |
regular or queue (for scaling) |
EXECUTIONS_DATA_PRUNE |
true |
Auto-prune old execution data |
EXECUTIONS_DATA_MAX_AGE |
336 |
Max execution age in hours |
N8N_METRICS |
false |
Enable Prometheus /metrics endpoint |
N8N_LOG_LEVEL |
info |
error, warn, info, debug |
N8N_LOG_OUTPUT |
console |
console, file (comma-separated) |
N8N_CONCURRENCY_PRODUCTION_LIMIT |
-1 |
Max concurrent production executions |
N8N_RUNNERS_ENABLED |
false |
Enable task runners for Code nodes |
GENERIC_TIMEZONE |
America/New_York |
Timezone for schedule triggers |
Use _FILE suffix for Docker Secrets (e.g., DB_POSTGRESDB_PASSWORD_FILE=/run/secrets/db_pass).
Examples
Example 1: Deploy n8n with PostgreSQL in production
User request: "Set up n8n in production with Docker Compose"
Actions taken:
$ mkdir n8n-production && cd n8n-production
# Generate secrets
$ openssl rand -hex 24
> a1b2c3d4e5f6...
# Create .env with POSTGRES_USER, POSTGRES_PASSWORD, POSTGRES_DB,
# ENCRYPTION_KEY, WEBHOOK_URL, GENERIC_TIMEZONE
# Create docker-compose.yml (Task A template)
$ docker compose up -d
> [+] Running 3/3
> ✔ Network n8n-production_default Created
> ✔ Container postgres Started
> ✔ Container n8n Started
$ docker compose logs n8n --tail 5
> n8n | Editor is now accessible via: http://localhost:5678
Example 2: Back up and restore workflows
User request: "Back up all my n8n workflows and credentials"
Actions taken:
$ docker exec -u node n8n n8n export:workflow --backup --output=/home/node/.n8n/backups/
> Successfully exported 12 workflows
$ docker exec -u node n8n n8n export:credentials --backup --output=/home/node/.n8n/backups/
> Successfully exported 8 credentials
# Copy backups out of the container
$ docker cp n8n:/home/node/.n8n/backups/ ./n8n-backups/
# Restore on a new instance
$ docker cp ./n8n-backups/ n8n-new:/home/node/.n8n/backups/
$ docker exec -u node n8n-new n8n import:workflow --separate --input=/home/node/.n8n/backups/
> Successfully imported 12 workflows
Example 3: Troubleshoot a failing instance
User request: "My n8n instance is crashing after update"
Actions taken:
$ docker compose logs n8n --tail 30
> error: Migration failed: column "x" already exists
# Rollback the last migration
$ docker exec -u node n8n n8n db:revert
> Reverted migration: AddColumnX1234567890
# Pin to previous working version in docker-compose.yml
# image: docker.n8n.io/n8nio/n8n:1.80.0
$ docker compose up -d
> n8n | Editor is now accessible via: http://localhost:5678
Guidelines
- Always set
N8N_ENCRYPTION_KEYexplicitly and back it up. Without it, credentials cannot be decrypted on a new instance. - Use PostgreSQL for any instance running more than a few workflows. SQLite doesn't handle concurrent writes well.
- Set
WEBHOOK_URLwhen behind a reverse proxy — webhooks fail silently without it. - Use
n8n export:credentials --decryptedwhen migrating between instances with different encryption keys. - Enable execution pruning (
EXECUTIONS_DATA_PRUNE=true) to prevent database bloat. - In queue mode, all instances must share the same
N8N_ENCRYPTION_KEYand PostgreSQL database. - Scale workers with
docker compose up -d --scale n8n-worker=N. - Run
n8n auditperiodically to detect security issues in your instance configuration. - For health checks, use
/healthz(basic) and/healthz/readiness(DB-aware). - Use
N8N_LOG_LEVEL=debugtemporarily when troubleshooting, then revert toinfo.