Deploy N8N
n8n + Postgres with external task runners.
Just deployed
/var/lib/postgresql/data
Just deployed
/home/node/.n8n
n8n-runners
Just deployed
Deploy and Host N8N on Railway
This variant: n8n with external task runners, so Python Code nodes work. n8n and Postgres plus n8n's official runners sidecar, which executes JavaScript and Python Code nodes in a separate container. 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
Since n8n 2.0, the Python Code node only runs on task runners in external mode, which the standard single-container setup does not have. This template deploys three services:
n8n: the editor, API, triggers and executions, with a volume at/home/node/.n8n. It hosts the task broker on port 5679 of the private network.n8n-runners: then8nio/runnersimage. Its launcher connects to the broker and starts JavaScript and Python runners on demand.Postgres: workflows, credentials and execution history.
Both n8n images are pinned to 2.40.7. The first boot runs n8n's database migrations, which takes about a minute. Then open the public URL and create the owner account right away: the first visitor to an unclaimed instance becomes its owner.
Common Use Cases
- Data cleanup and transformation in Python Code nodes
- Keep user-written code out of the n8n process, which holds your credentials and encryption key
- Teams where several people write Code nodes and you want n8n's recommended isolation
Dependencies for N8N Hosting
- Nothing to bring. Every secret (Postgres password, n8n encryption key, runner auth token) 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
- Images: https://hub.docker.com/r/n8nio/n8n and https://hub.docker.com/r/n8nio/runners
- Task runner docs: https://docs.n8n.io/hosting/configuration/task-runners/
Implementation Details
- What Code nodes may import is set on
n8n-runners, and the defaults are deliberately narrow:N8N_RUNNERS_STDLIB_ALLOW: Python standard library modules. Ships with data-processing modules only (json,re,datetime,math,statistics,collections,hashlib,csvand similar), notos,sys,subprocessorsocket. Set it to*to allow all.NODE_FUNCTION_ALLOW_BUILTIN(crypto) andNODE_FUNCTION_ALLOW_EXTERNAL(moment): the JavaScript equivalents.N8N_RUNNERS_EXTERNAL_ALLOW: third-party Python packages. The stock image has none; add them by extendingn8nio/runnersas described in n8n's docs.
- How the allowlists apply. The launcher only reads them from its JSON config, so the start command writes a copy of the image's
/etc/n8n-task-runners.jsonwith these four variables applied and pointsN8N_RUNNERS_CONFIG_PATHat it. - Shared secret.
N8N_RUNNERS_AUTH_TOKENis generated onn8nand referenced fromn8n-runners, and the broker listens on the private network only. - Other N8N variants. This creator also publishes n8n with Postgres, queue mode with workers, workers plus webhook processors, and a single-service SQLite version.
- Back up
N8N_ENCRYPTION_KEY. Without it, stored credentials cannot be decrypted. - Custom domain. After adding one, set
N8N_EDITOR_BASE_URLandN8N_WEBHOOK_URLonn8ntohttps://your-domain. - Upgrading.
n8nio/runnersmust match then8nio/n8nversion exactly. Change both tags together and redeploy both services.
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
n8n-runners
n8nio/runners:2.40.7