Deploying an n8n App
Introduction
n8n is an open-source workflow automation platform built on Node.js. Deploying n8n with a Dockerfile on Klutch.sh provides reproducible builds, managed secrets, and persistent storage for credentials and workflows—all configured from klutch.sh/app. This guide covers installation, repository prep, a production-ready Dockerfile, deployment steps, Nixpacks overrides, sample API usage, and production tips.
Prerequisites
- A Klutch.sh account (sign up)
- A GitHub repository containing your n8n Dockerfile (GitHub is the only supported git source)
- Database credentials if you externalize data (PostgreSQL recommended); otherwise, use the default SQLite file storage
- Domain and TLS for secure access
For onboarding, see the Quick Start.
Architecture and ports
- n8n serves HTTP on internal port
5678; choose HTTP traffic. - Persistent storage is required for credentials, workflows, and SQLite (if used).
- For Postgres deployments, run the database as a separate Klutch.sh TCP app on port
8000and connect on5432.
Repository layout
n8n/├── Dockerfile # Must be at repo root for auto-detection└── README.mdKeep secrets out of Git; store them in Klutch.sh environment variables.
Installation (local) and starter commands
Validate locally before pushing to GitHub:
docker build -t n8n-local .docker run -p 5678:5678 -e N8N_BASIC_AUTH_USER=admin -e N8N_BASIC_AUTH_PASSWORD=changeme n8n-localDockerfile for n8n (production-ready)
Place this Dockerfile at the repo root; Klutch.sh auto-detects it (no Docker selection in the UI):
FROM n8nio/n8n:latest
ENV N8N_PORT=5678
EXPOSE 5678CMD ["n8n", "start"]Notes:
- Pin the image tag for stability (e.g.,
n8nio/n8n:1.41.x) and upgrade intentionally. - If you mount custom nodes or assets, add COPY steps and ensure writable paths.
Environment variables (Klutch.sh)
Set these in Klutch.sh before deploying:
N8N_PORT=5678WEBHOOK_URL=https://example-app.klutch.sh/N8N_HOST=example-app.klutch.shN8N_PROTOCOL=httpsN8N_BASIC_AUTH_ACTIVE=trueN8N_BASIC_AUTH_USER=<admin-user>N8N_BASIC_AUTH_PASSWORD=<admin-password>- For Postgres:
DB_TYPE=postgresdb,DB_POSTGRESDB_HOST=<db-host>,DB_POSTGRESDB_PORT=5432,DB_POSTGRESDB_DATABASE=<db-name>,DB_POSTGRESDB_USER=<db-user>,DB_POSTGRESDB_PASSWORD=<db-password> - For SQLite (default):
DB_TYPE=sqlite - Optional encryption key:
N8N_ENCRYPTION_KEY=<secure-random>
If you deploy without the Dockerfile and need Nixpacks overrides:
NIXPACKS_START_CMD=n8n startNIXPACKS_NODE_VERSION=18
Attach persistent volumes
In Klutch.sh storage settings, add mount paths and sizes (no names required):
/home/node/.n8n— credentials, workflows, and SQLite data./home/node/.n8n/logs— optional logs if you store them on disk.
Ensure these paths are writable inside the container.
Deploy n8n on Klutch.sh (Dockerfile workflow)
- Push your repository—with the Dockerfile at the root—to GitHub.
- Open klutch.sh/app, create a project, and add an app.
- Select HTTP traffic and set the internal port to
5678. - Add the environment variables above, including database settings (Postgres or SQLite) and basic auth credentials.
- Attach persistent volumes for
/home/node/.n8n(and/home/node/.n8n/logsif used) sized for your workflow data. - Deploy. Access your n8n instance at
https://example-app.klutch.shand start building workflows.
Sample API usage
List workflows (requires basic auth/token):
curl -X GET "https://example-app.klutch.sh/rest/workflows" \ -u "<admin-user>:<admin-password>"Health checks and production tips
- Add an HTTP probe to
/healthzor/for readiness. - Enforce HTTPS at the edge; forward internally to port
5678. - Use Postgres for production; keep credentials and encryption keys in Klutch.sh secrets and rotate them regularly.
- Monitor volume usage on
/home/node/.n8n; resize before it fills. - Pin image versions and test upgrades in staging before production.
n8n on Klutch.sh combines reproducible Docker builds with managed secrets, persistent storage, and flexible HTTP/TCP routing. With the Dockerfile at the repo root, port 5678 configured, and your database set, you can run secure, scalable automations without extra YAML or workflow overhead.