
Deploy n8n [Aug 26]
n8n workflow automation + Postgres — 400+ integrations · Updated Aug 26
Just deployed
Just deployed
/var/lib/postgresql/data
Deploy and Host n8n + Postgres on Railway
About Hosting
Railway provides a streamlined platform for deploying web applications and databases. This template runs n8n — the popular workflow automation platform with 400+ integrations — on Railway with a PostgreSQL database. n8n's official Docker image is pinned to a stable version, so deploys are reproducible and updates are a one-line bump.
Why Deploy
Deploying this template gives you a self-hosted automation platform in minutes:
- Workflow automation — build no-code/code workflows with 400+ integrations (HTTP, webhooks, AI, Slack, Gmail, and more)
- Postgres-backed — workflows, credentials, and execution history stored in PostgreSQL 16 instead of the default SQLite, ready for production
- Zero manual setup — database migrations run automatically on boot; the Railway deploy wizard prompts for the encryption key
- Cheap to run — the n8n service supports sleep (serverless) when idle; the Postgres service stays warm
Common Use Cases
- Automation server — centralize integrations, webhooks, and scheduled jobs for your SaaS
- AI workflows — connect LLM nodes with your data and APIs (n8n has native AI/agent nodes)
- Team productivity — notifications, syncs, and internal tooling without writing glue code
- Self-hosted alternative — replace hosted automation tools with your own instance and data control
Dependencies for
This template requires:
Deployment Dependencies
- PostgreSQL 16 — add the Postgres service in the Railway dashboard; the template maps
DB_*variables automatically - N8N_ENCRYPTION_KEY — required to encrypt stored credentials; generate with
openssl rand -hex 16(the deploy wizard will prompt you) - n8n 2.33.x image pinned in the
Dockerfile(bump the tag to update)
Getting Started
- Click Deploy on Railway
- In the deploy wizard, provide
N8N_ENCRYPTION_KEY(or generate one withopenssl rand -hex 16) - Add a Postgres service — Railway injects the connection variables automatically
- Open the generated domain and create your n8n account
Next Steps
- Webhooks — set
WEBHOOK_URLtohttps://${{RAILWAY_PUBLIC_DOMAIN}}/so webhook URLs are reachable - Custom domain — add one to your n8n service and set
N8N_HOST - Sleep (serverless) — enable sleep on the n8n service so it pauses when idle; Postgres stays awake
License
n8n is fair-code (Sustainable Use License). This template's wrapper and configuration are MIT.
Template Content
PORT
DB_TYPE
DB_POSTGRESDB_HOST
DB_POSTGRESDB_PORT
DB_POSTGRESDB_USER
N8N_ENCRYPTION_KEY
DB_POSTGRESDB_DATABASE
DB_POSTGRESDB_PASSWORD
PGDATA
PGPORT
POSTGRES_DB
POSTGRES_USER
SSL_CERT_DAYS
RAILWAY_DEPLOYMENT_DRAINING_SECONDS