Deploy n8n Queue Stack [Updated Sep'26]

Queue-mode n8n: main, worker, Redis, Postgres. All images pinned.

Deploy n8n Queue Stack [Updated Sep'26]

/var/lib/postgresql/data

Just deployed

Just deployed

/data

n8n-runner

n8n-io/runners

Just deployed

n8n-worker

n8n-io/n8n

Just deployed

n8n visual workflow canvas with connected nodes

Deploy and Host n8n Queue Stack on Railway

n8n is a fair-code workflow automation platform and the leading self-hosted alternative to Zapier — same visual canvas, 400+ integrations, no per-task billing, no data leaving your infrastructure. Most self-hosted n8n runs as one container serving the editor, webhooks and executions alike, which holds until a single slow run freezes the UI. This template wires n8n in queue mode across four services with generated secrets and private networking configured, so you get a production execution tier on your first deploy.

What This Template Deploys

ServicePurpose
n8nEditor, REST API and webhooks on port 5678. The only public service, health-checked at /healthz.
n8n-workerSame image started with n8n worker. Pulls jobs off the queue and executes them. Scale this one.
PostgresWorkflows, encrypted credentials, execution history. Volume at /var/lib/postgresql/data.
RedisBullMQ job broker. Volume at /data.

All four talk over Railway's private network, so queue and database traffic never touches the public internet. Only Postgres and Redis carry volumes — neither n8n container holds state.

About Hosting

The encryption key is the trap that bites everyone. N8N_ENCRYPTION_KEY must be byte-identical across every n8n service. Get it wrong and nothing fails at deploy — the editor loads, workflows save, then executions fail at runtime with decryption errors that look like an API problem.

Queue mode cannot run on SQLite. Single-container guides call the database optional. Here it isn't — the main process and worker need a shared durable store, so Postgres is mandatory.

Execution history grows without limit by default. n8n keeps every run, binary payloads included, until told otherwise. A busy instance fills a volume in weeks, so set pruning early.

Production webhooks break without an explicit public URL. n8n builds webhook URLs from its host config. Left unset it hands out localhost addresses nothing external can reach, and the failure is silent — the workflow never fires.

n8n is memory-bound before it is CPU-bound. Four vCPU with 8 GB beats eight vCPU with 4 GB. Budget 512 MB–1 GB per worker and add RAM or replicas rather than cores.

Typical cost: ~$15–25/month at light traffic, on Railway's rates of $10/GB/month RAM, $20/vCPU/month CPU and $0.15/GB/month volumes. Cost scales with worker replicas, not workflow count.

How It Compares

n8n (self-hosted)ZapierMakeActivepieces
Self-hostingYes, full stackNoNoYes
BillingInfrastructure onlyPer taskPer operationInfra or cloud
Integrations400+6,000+2,000+~280
Custom codeJavaScript, PythonLimitedLimitedTypeScript
LicenceFair-codeProprietaryProprietaryMIT

The honest edge: Zapier has far more integrations and you will hit services n8n has no node for. The HTTP Request node covers any REST API, but it costs an hour Zapier would have saved. That hour buys unmetered executions and credentials that never sit on someone else's server — worth it for many or long-running workflows, not a handful of simple ones.

Deploy in Under 5 Minutes

  1. Click Deploy and pick a workspace. Railway provisions all four services and generates the encryption key and database credentials.
  2. Wait for n8n to pass its health check at /healthz. The worker may restart once while Postgres and Redis come up.
  3. Open the generated Railway domain. Self-hosted n8n has no default credentials — the first page is the owner-account form, and whoever submits it owns the instance.
  4. Build a throwaway workflow: Manual Trigger, then a Code node returning [{ json: { ok: true } }]. Execute it.
  5. Open Executions and confirm the run shows as finished — it travelled main → Redis → worker, proving the stack is wired.

Tip: claim the owner account yourself before sharing the domain.

n8n editor showing a workflow and its execution result

Common Use Cases

  • AI agents and RAG assistants — chain a chat model, a vector store and your internal APIs as tools, with prompts and embeddings never leaving your infrastructure.
  • Scheduled data movement — cron-triggered syncs between Postgres, warehouses, spreadsheets and SaaS tools, plus nightly reports and cleanups.
  • Internal API orchestration — one webhook that fans out to several services and returns a single normalised payload.
  • Long-running jobs — bulk backfills and file transforms, where queue mode pays off: the run occupies a worker, not the editor.

Configuration

VariableRequiredDescription
N8N_ENCRYPTION_KEYYesEncrypts stored credentials. Generated at deploy; identical on both n8n services.
EXECUTIONS_MODEYesqueue, so the main process enqueues work instead of running it.
DB_TYPEYespostgresdb. Queue mode does not support SQLite.
DB_POSTGRESDB_*, QUEUE_BULL_REDIS_*YesPostgres and Redis connection details, set as reference variables on private hostnames.
WEBHOOK_URLYesYour public Railway domain. Without it, production webhook URLs are unreachable.
EXECUTIONS_DATA_PRUNENotrue deletes old executions automatically. Recommended.
GENERIC_TIMEZONENoTimezone for cron triggers. Defaults to UTC.

Never rotate N8N_ENCRYPTION_KEY on a live instance. Every credential is encrypted with it. Change it and you re-enter them all by hand — there is no recovery path.

Set GENERIC_TIMEZONE before building cron workflows. Changing it later shifts every existing schedule's fire time at once.

Dependencies for n8n Queue Stack Hosting

  • A Railway account — Hobby at $5/month includes $5 of usage; expect roughly $15–25/month total for this stack.
  • Bundled services — Postgres 18 and Redis 8.2, provisioned by the template. Node.js 22 ships inside the n8n image.
  • Volumes — Postgres at /var/lib/postgresql/data, Redis at /data. Without them a redeploy destroys every workflow and credential.
  • Optional add-ons — a task runner (ghcr.io/n8n-io/runners:2.32.6-distroless) for isolated Code-node execution, and an S3 bucket for off-platform backups.

Deployment Dependencies

Implementation Details

Both n8n services run ghcr.io/n8n-io/n8n:2.32.6, differing only in start command: the main service serves the editor and API on 5678 behind the Railway domain, while n8n-worker starts with n8n worker and holds no public route. Postgres and Redis are reached by private hostname through reference variables, and all four images are pinned rather than tracking latest, so a redeploy months from now reproduces what you tested.

The request path is Railway edge → n8n:5678 → Redis → n8n-worker. That indirection protects the editor: a ten-minute workflow occupies a worker, and the UI stays responsive because it was never going to run the job. Scale by raising replicas on n8n-worker, each pulling independently from the same queue, and leave n8n at one replica. Task runners are not shared — give each worker replica its own on port 5679.

For backups, only Postgres needs protecting — Redis holds in-flight jobs and is safe to lose. Point a scheduled pg_dump at S3: a volume is durable, not a backup.

Frequently Asked Questions

Why do I need both Postgres and Redis? Postgres is the durable store for workflows, credentials and execution history. Redis is the job broker queue mode runs on — without it the main process runs workflows itself and one heavy job blocks the editor.

What happens if the encryption keys don't match? The editor works and workflows save, but executions fail at runtime with decryption errors — the most common self-hosted n8n failure, and it looks like an integration bug rather than a config bug.

How do I scale this? Raise replicas on n8n-worker. Throughput scales close to linearly until Postgres becomes the bottleneck. Keep n8n at one replica — two editors against one queue causes duplicate trigger registration.

Will my workflows survive a redeploy? Yes. Everything lives in Postgres on a volume and neither n8n container holds state. Community nodes reinstall on boot with N8N_REINSTALL_MISSING_PACKAGES=true.

Can I run Python in Code nodes? Yes, inside the worker process. For isolated execution, add a task runner pointed at the worker's broker on port 5679.

Is n8n free for commercial use? Yes for automating your own operations. The Sustainable Use License only restricts reselling n8n itself as a hosted product to third parties.

Why Deploy n8n Queue Stack 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 Queue Stack 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. Four services, pinned images and generated secrets, wired at deploy time — all that's left is to claim your owner account.


Template Content

More templates in this category

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

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

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

Railway Templates
870