Deploy N8N
Deploy n8n with Postgres.
Just deployed
/var/lib/postgresql/data
Just deployed
/home/node/.n8n
Deploy and Host N8N on Railway
This variant: n8n with Postgres. One n8n instance on a volume, backed by Railway's managed Postgres. n8n is an open-source workflow automation platform with 400+ integrations, AI agent nodes and a visual editor: a self-hosted alternative to Zapier and Make with no per-execution fees.
About Hosting N8N
This template deploys two services: n8n (the editor, API, triggers and executions in one process) and Postgres (workflows, credentials and execution history). n8n is pinned to 2.40.7.
The first boot runs n8n's database migrations, which takes about a minute before the healthcheck on /healthz/readiness turns green. Then open the public URL and create the owner account right away: the first visitor to an unclaimed instance becomes its owner.
The n8n service keeps a volume at /home/node/.n8n for binary files from executions and for community nodes you install from the UI. The volume also means Railway never runs two copies of n8n side by side during a redeploy, so Schedule triggers do not fire twice.
Common Use Cases
- Replace Zapier or Make: sync CRMs, spreadsheets, email and Slack without per-task pricing
- Build AI agents and chatbots with the built-in LangChain nodes and any LLM provider
- Receive webhooks from Stripe, GitHub or your own apps and run backend logic on them
Dependencies for N8N Hosting
- Nothing to bring. Every secret (Postgres password, n8n encryption key) is generated at deploy time.
- Optional: API keys for the services your workflows connect to, added later as n8n credentials.
Deployment Dependencies
- n8n: https://github.com/n8n-io/n8n
- Docker image: https://hub.docker.com/r/n8nio/n8n
- Self-hosting docs: https://docs.n8n.io/hosting/
Implementation Details
-
Other N8N variants. This creator also publishes n8n with queue-mode workers, with workers plus webhook processors, a single-service SQLite version, and a version with external task runners for Python Code nodes.
-
Back up
N8N_ENCRYPTION_KEY. It encrypts every credential in Postgres. Lose it and those credentials cannot be decrypted, even with a database backup. -
Custom domain. After adding one, set
N8N_EDITOR_BASE_URLandN8N_WEBHOOK_URLonn8ntohttps://your-domainso webhook and OAuth URLs use it. -
Volume permissions. Railway mounts volumes owned by root. The start command runs as root only long enough to hand
/home/node/.n8nto thenodeuser, then starts n8n asnode:test "$(stat -c %U /home/node/.n8n)" = node || chown -R node:node /home/node/.n8n export HOME=/home/node; exec su -p -s /bin/sh node -c "exec /sbin/tini -- /docker-entrypoint.sh" -
Code nodes run on n8n's internal JavaScript task runner. Python Code nodes need external task runners, which the task-runners variant provides.
-
Upgrading. Change the image tag on
n8nto a newern8nio/n8nversion and redeploy; migrations run on boot. -
Execution history is pruned after 14 days or 10,000 executions (
EXECUTIONS_DATA_MAX_AGE,EXECUTIONS_DATA_PRUNE_MAX_COUNT), which keeps the Postgres volume from growing without bound.
Why Deploy N8N on Railway?
Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.
By deploying N8N on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.
Template Content