Deploy n8n
n8n on Postgres with the owner account set at deploy, so nobody else can
Just deployed
Just deployed
Deploy and Host n8n on Railway
n8n is a workflow automation tool: visual flows with hundreds of integrations, webhooks, schedules, code steps and AI agent nodes.
This template runs the official image (2.40.7) on Postgres, with n8n's folder on a volume for community nodes and binary data.
About Hosting n8n
A fresh n8n asks whoever opens it first to create the owner account. On a public URL that can be anyone, and most templates leave it open until you get there. This one sets the owner up for you: the deploy form asks for your email, a password is generated into N8N_OWNER_PASSWORD, and a start step creates the owner once n8n is ready, then signs in to confirm it. Open N8N_URL and sign in with that email and password.
My first version of that step fired as soon as /healthz answered, which is while the database migrations are still running, and in my test the owner it created didn't stick: a second setup request from another address then succeeded. The step now waits for /healthz/readiness and retries until signing in works.
Before publishing I tested the final version on a fresh deploy. The start step reported the owner as set up, a setup request from another address was refused with "Instance owner already setup", and the owner signed in with the owner role. A workflow with a webhook trigger, created and activated through the API, ran with status success when I called the webhook. After a restart the workflow was still active and its webhook still answered.
Common Use Cases
- Connect your apps with flows triggered by webhooks, schedules or app events
- Build AI agent workflows that call models and tools, with credentials stored encrypted
Dependencies for n8n Hosting
Nothing beyond the template: Postgres is included. Integrations need their own credentials, added in n8n.
Deployment Dependencies
- n8n: https://github.com/n8n-io/n8n
- Docs: https://docs.n8n.io/hosting/
- Image:
n8nio/n8n:2.40.7 - The wrapper this template builds: https://github.com/dektionstudio/railway-template-images/tree/main/n8n
Implementation Details
N8N_OWNER_EMAIL / N8N_OWNER_PASSWORD # owner account, set up on first start
N8N_ENCRYPTION_KEY # generated; encrypts stored credentials, keep it
WEBHOOK_URL=https:/// # change it when you add a custom domain
DB_TYPE=postgresdb, DB_POSTGRESDB_* # Postgres over the private network
N8N_RUNNERS_ENABLED=true # Code nodes run in task runners
The container starts as root only to hand the volume to n8n's node user; the image has no package manager, so the start step drops privileges through Node itself. To upgrade, set N8N_VERSION (an image tag) on the n8n service.
n8n logs that internal task runner mode is deprecated. It still works in 2.40.7; upstream recommends a separate runner process for larger setups.
Idle, n8n used 0.40 GB of RAM and Postgres 0.14 GB.
Why Deploy n8n on Railway?
Webhooks need a public HTTPS address that stays up, and here it's yours from the first minute with nobody else able to claim the owner account. Both services come to about $5 a month in RAM at idle.
Template Content
N8N_OWNER_EMAIL
Email of the owner account, set up on first start. Sign in with it and N8N_OWNER_PASSWORD