n8n-self-host
安装方式
先用 Prompt 核对来源与依赖。也可下载安装包。
用 AI 助手安装
复制提示词,让助手先核对固定版本和依赖。
查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "n8n-self-host":https://skillpi.com/zh/skills/deepskill-2266c6f8079f5910cdee59882fe64b267ce0d20e646ed170f41115cd84387fb5。安装前核对上游来源和版本:https://github.com/TerminalSkills/skills。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。
来源与配置
github.com
配置方式待核实
请查看原始来源中的适用工具、依赖和权限要求。
安装实测待补充
n8n 自行托管专家:关于自行托管、配置、扩展和管理 n8n 实例的指导。适用于使用 Docker 安装、在生产中设置、配置环境变量、使用工作节点扩展、备份与恢复工作流、通过 CLI 或 REST API 管理、监控与排查问题、使用 PostgreSQL 或通过反向代理部署的场景;设计工作流和节点请参见 n8n‑workflow。
介绍来源: third_party · TerminalSkills · 1.0.0 参考来源
SkillPi 解读
- 软件、账号及付费要求
- 翻译待完成,请参阅来源文档。
- 实测状态
- 未测试
文件浏览
Frontmatter
name: n8n-self-host
description: >-
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.
license: Apache-2.0
compatibility: "Requires Docker 20+ or Node.js 18+ for n8n installation"
metadata:
author: terminal-skills
version: "1.0.0"
category: devops
tags: ["n8n", "self-hosting", "docker", "postgresql", "infrastructure"]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.
当前收录版本
1.0.0
质量评测
满分100 · 来自 SkillPi LAB 实验室的评测报告。
亮点
- 覆盖 n8n 自行托管的完整运维生命周期,包括生产部署、扩展、备份恢复、API 管理、监控排错等
- 直接解决用户明确的核心任务痛点,显著提升 DevOps 效率
- 提供了详细的 Docker Compose 配置、CLI 命令、REST API 调用等实用内容
亮点
- 触发词精准完整,覆盖多种变体,边界清晰
- 明确列出了 12 个具体触发场景,包括 Docker 安装、生产环境设置、环境变量配置等
- 明确区分了与 n8n-workflow 的边界,避免功能重叠
亮点
- Phase/步骤清晰,有出口条件,含端到端示例
- frontmatter完整,包含 name、description、license、compatibility、metadata 等信息
- 单文件结构良好,分为 Overview、Instructions、Examples、Guidelines 等清晰章节
亮点
- 工具来源明确,参数正确,覆盖主要异常
- 不可逆操作有确认机制,如数据库迁移回滚、故障排查等
- 强调了关键安全实践如 ENCRYPTION_KEY 备份、PostgreSQL 推荐等
取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。
正文静态检测
100 / 100 · skillpi-20261123-no-r3-v1
正文未命中当前规则。
分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。
权限与使用前检查
根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。
-
账号、密钥或授权
使用专用、最小权限账号,不把密钥粘贴到公开内容或命令日志;核对接收数据的服务与租户。
主文档提及 · 第 138, 139, 140, 141, 167 行
文档引用的域名或地址
这些地址可能用于文档链接或示例,不是已批准的联网清单。使用前核对实际目的地及发送的数据。
- localhost
安全评级与访问范围
safe · 静态证据核验,不代表运行安全保证。
翻译待完成,请参阅来源文档。
使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。
用户讨论
还没有已核实的点评。