Deploy n8n

Self-hosted n8n in queue mode: scale workers with Redis and Postgres.

Deploy n8n

Worker

n8nio/n8n

Just deployed

/var/lib/postgresql/data

Just deployed

/bitnami

Primary

n8nio/n8n

Just deployed

Deploy and Host n8n Queue Mode on Railway

n8n workflow automation logo

n8n is the workflow automation platform with 208,000+ GitHub stars, connecting 400+ apps, APIs and AI models in a visual editor with code when you need it. This template runs n8n in queue mode on Railway: a main instance for the editor and webhooks, a separate worker that executes workflows, Redis as the job queue and Postgres for storage. Add more workers whenever volume grows. Zapier's Pro plan includes 750 tasks for $19.99/month, and n8n Cloud Pro is €50/month for 10,000 executions. Self-hosted n8n has no execution cap and costs about $10–20/month for the whole stack.


What This Template Deploys

ServicePurpose
PrimaryThe main n8n process (n8n start) with a public HTTPS domain: the editor UI, REST API, webhooks and triggers. It puts executions on the queue.
WorkerA dedicated n8n worker process that picks jobs off the queue and runs them. Scale it out with replicas.
RedisThe Bull job queue between Primary and Worker, persisted to a volume at /bitnami.
PostgresPostgres 17 storing workflows, credentials (encrypted), executions and users, on a persistent volume.

The four services talk over Railway's private network, dual-stack, so IPv6 works. Primary and Worker share the same encryption key through a reference variable, so credentials saved in the editor decrypt correctly on every worker.


About Hosting n8n Queue Mode

A single n8n instance does everything in one process: it serves the editor, receives webhooks and runs every workflow. That's fine until a heavy workflow, a burst of webhooks or a long AI agent run makes the editor sluggish or drops requests. Queue mode splits the work: the main instance only receives triggers and queues them in Redis, and workers execute them. One slow workflow no longer blocks everything else, and you add capacity by adding workers instead of rebuilding your server.

On Railway, queue mode is ready from the first deploy. Redis and Postgres are wired in through reference variables, HTTPS is automatic, the proxy headers are trusted so n8n sees real HTTPS requests, and manual runs from the editor are also sent to workers. To scale, raise the Worker service's replica count in Railway, with no extra configuration.

Keep the encryption key safe. N8N_ENCRYPTION_KEY is generated on Primary and shared with the Worker. It encrypts every saved credential, so never change it after setup, or all stored credentials become unreadable.

Typical cost: ~$10–20/month on Railway for Primary, one Worker, Redis and Postgres, with no limit on executions. Each extra worker adds roughly the cost of one small service. n8n Cloud Pro is €50/month for 10,000 executions.


Deploy n8n Queue Mode in Under 5 Minutes

  1. Click Deploy on Railway. Postgres, Redis, Primary and Worker start together (about 2–3 minutes).
  2. Open the Primary service's public URL and create the owner account.
  3. Build a workflow, or import one from n8n's template library.
  4. Open a Webhook node: its production URL already uses your Railway domain, because WEBHOOK_URL is preset.
  5. Activate the workflow. Executions now run on the Worker; watch them in the Executions list.

No Kubernetes. No Redis setup. No execution limits.


Common Use Cases

  • Self-hosted Zapier alternative at scale. Unlimited workflows and executions for a flat hosting cost.
  • High-volume webhooks. E-commerce events, form submissions and payment notifications without dropped requests.
  • AI agents and LLM pipelines. Long-running agent and RAG workflows on workers, away from the editor.
  • Data syncing between apps. CRM, spreadsheets, databases and SaaS tools kept in sync on schedules.
  • Internal automation for teams. One n8n for the whole company, with shared credentials and workflows.
  • Batch jobs. Nightly reports, data cleanups and imports that run in parallel across workers.
  • Agencies running client automations. Many active workflows on one scalable stack.

Configuration

VariableRequiredDescription
EXECUTIONS_MODE✅ Setqueue on both Primary and Worker. This turns on queue mode.
N8N_ENCRYPTION_KEY🔐 Auto-generatedEncrypts credentials. Generated on Primary and referenced by Worker. Never change it.
QUEUE_BULL_REDIS_HOST, _PORT, _USERNAME, _PASSWORD✅ Auto-injectedRedis queue connection over the private network.
DB_POSTGRESDB_HOST, _DATABASE, _USER, _PASSWORD✅ Auto-injectedPostgres connection, shared by Primary and Worker.
WEBHOOK_URL✅ Auto-injectedPublic base URL for Webhook and Form node URLs, from Primary's Railway domain.
N8N_EDITOR_BASE_URL✅ Auto-injectedPublic editor URL from Primary's Railway domain.
OFFLOAD_MANUAL_EXECUTIONS_TO_WORKERS✅ Settrue. Test runs from the editor also go to workers.
N8N_TRUST_PROXY✅ Settrue, so n8n reads Railway's forwarded headers and builds HTTPS links.
NODE_OPTIONSOptional--max_old_space_size=8192, the Node.js heap ceiling. Lower it on small plans.
QUEUE_BULL_REDIS_DUALSTACK✅ Settrue for IPv6 on Railway's private network.

Using a custom domain? Add it to the Primary service, then set WEBHOOK_URL and N8N_EDITOR_BASE_URL to https:// plus your domain and redeploy. Reactivate workflows so their webhooks register on the new URL.

Scaling workers. In the Worker service's settings, increase replicas. Each replica runs workflows in parallel. You can also set N8N_CONCURRENCY_PRODUCTION_LIMIT or the worker --concurrency flag to control how many jobs each one takes.


n8n Queue Mode on Railway vs. Alternatives

n8n on Railway (queue mode)n8n CloudZapierMake
Monthly cost~$10–20 usage€20 Starter, €50 Pro (annual)$19.99 Pro (annual), $69 TeamFree tier, then paid plans
Self-hosted✅ Yes❌ No❌ No❌ No
Execution limits✅ None❌ 2,500 or 10,000 per month❌ 750 tasks on Pro entry❌ 1,000 credits on Free
Horizontal scaling✅ Add workers⚠️ Managed by n8nManagedManaged
Custom code and community nodes✅ Yes⚠️ Limited⚠️ Code steps⚠️ Limited
Data stays on your infrastructure✅ Your Postgres❌ n8n servers❌ Zapier servers❌ Make servers
License⚠️ Sustainable Use (source-available)❌ Hosted❌ Proprietary❌ Proprietary

Dependencies for n8n Queue Mode Hosting

  • Railway account. Hobby works to start; Pro gives headroom for multiple workers and heavier workflows.
  • Accounts and API keys for the apps your workflows connect to.
  • Optional: a custom domain for webhook URLs that never change.

Deployment Dependencies

Implementation Details

Primary runs n8n start and Worker runs n8n worker, both from the official n8nio/n8n image and listening on :: for Railway's IPv6 private network. Executions are queued in Redis through Bull, and every process reads and writes workflows and results in Postgres, so any worker can pick up any job. Primary has no volume: workflows, credentials and settings all live in Postgres.

The image tracks the latest n8n release. Pin a version tag on both Primary and Worker once you depend on it, and upgrade them together.


Frequently Asked Questions

What is n8n queue mode, and when do I need it? Queue mode separates triggers from execution: the main instance queues jobs in Redis and workers run them. Use it when you have many active workflows, bursts of webhooks or long-running executions.

How much does it cost compared to n8n Cloud or Zapier? About $10–20/month on Railway for the full stack, with unlimited executions. n8n Cloud Pro is €50/month for 10,000 executions, and Zapier Pro starts at $19.99/month for 750 tasks.

Why do my webhook URLs still show the old domain after adding a custom domain? n8n builds them from WEBHOOK_URL. Update it on the Primary service to your new domain with https://, redeploy, then deactivate and reactivate the workflow.

Do I lose workflows or credentials on redeploy? No. Workflows, credentials, executions and users are stored in Postgres on its volume, and the queue is in Redis on its volume. Redeploys keep everything.

How do I add more workers? Increase the Worker service's replica count in Railway, or duplicate the service. New workers connect to the same Redis and Postgres automatically and start taking jobs.

Can I use n8n commercially if I self-host it? Yes, for your own business's internal automations. n8n's Sustainable Use License doesn't let you resell n8n as a hosted service to others without a commercial agreement.


Why Deploy and Host n8n Queue Mode 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 in queue mode on Railway, you get production-grade automation that scales by adding workers, with unlimited executions and your data in your own Postgres, for a predictable monthly cost.


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
103
View Template
Postgres Backup
Cron-based PostgreSQL backup to bucket storage

Railway Templates
870