Deploy N8N

n8n + Postgres with external task runners.

Deploy N8N

/var/lib/postgresql/data

Just deployed

/home/node/.n8n

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: the n8nio/runners image. 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

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, csv and similar), not os, sys, subprocess or socket. Set it to * to allow all.
    • NODE_FUNCTION_ALLOW_BUILTIN (crypto) and NODE_FUNCTION_ALLOW_EXTERNAL (moment): the JavaScript equivalents.
    • N8N_RUNNERS_EXTERNAL_ALLOW: third-party Python packages. The stock image has none; add them by extending n8nio/runners as 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.json with these four variables applied and points N8N_RUNNERS_CONFIG_PATH at it.
  • Shared secret. N8N_RUNNERS_AUTH_TOKEN is generated on n8n and referenced from n8n-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_URL and N8N_WEBHOOK_URL on n8n to https://your-domain.
  • Upgrading. n8nio/runners must match the n8nio/n8n version 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

More templates in this category

View Template
N8N Main + Worker
Deploy and Host N8N with Inactive worker.

jakemerson
120
View Template
Evolution API with n8n
Automate WhatsApp workflows with Evolution API, n8n, and Postgres.

codestorm
95
View Template
Postgres Backup
Cron-based PostgreSQL backup to bucket storage

Railway Templates
870