---
title: "Deploy N8N (w/ task runners)"
description: "n8n with external task runners for isolated and reliable code execution"
category: "Automation"
url: https://railway.com/deploy/n8n-with-task-runners
---

# Deploy N8N (w/ task runners)

n8n with external task runners for isolated and reliable code execution

**[Deploy N8N (w/ task runners) on Railway](https://railway.com/template/n8n-with-task-runners)**

- **Creator:** INF Labs
- **Category:** Automation

## Template content

### Postgres https://devicons.railway.app/i/postgresql.svg

- **Image:** ghcr.io/railwayapp-templates/postgres-ssl:18

### Main https://devicons.railway.app/n8n

- **Image:** n8nio/n8n:latest
- **Health check:** /healthz
- **Public domain:** Yes

### Runners https://devicons.railway.app/n8n

- **Image:** n8nio/runners

## Documentation

# Deploy and Host n8n with Task Runners on Railway

n8n is a powerful workflow automation platform for connecting APIs, applications, databases, AI models, and business processes. This template pairs n8n with PostgreSQL and dedicated external Task Runners, providing a cleaner architecture for executing Code node tasks separately from the main n8n process.

## About Hosting n8n with Task Runners

![N8N](https://imgur.com/ypXsnwZ.png)

This template deploys a self-hosted n8n stack with **PostgreSQL** for persistent application data and dedicated **n8n Task Runners** for isolated task execution.

The Main service hosts the n8n editor, APIs, webhooks, scheduling, and workflow orchestration. PostgreSQL stores workflows, credentials, execution history, and other persistent n8n data. The separate Task Runners service connects to n8n's task broker and executes supported Code node tasks outside the main n8n process.

Unlike n8n Queue Mode deployments, this template does **not require Redis or separate workflow workers**, keeping the infrastructure smaller while still providing dedicated task execution.

## Included Architecture

| Service        | Purpose                                                                       |
| -------------- | ----------------------------------------------------------------------------- |
| **Main**       | n8n editor, API, webhooks, scheduling, and workflow orchestration             |
| **Runners**    | Dedicated external Task Runners for Code node task execution                  |
| **PostgreSQL** | Persistent database for workflows, credentials, executions, and configuration |

## Common Use Cases

* Build AI-powered workflows and AI agents
* Connect APIs, databases, SaaS applications, and internal systems
* Run JavaScript and supported Python tasks through dedicated Task Runners
* Automate backend processes and API integrations
* Build webhook-driven automation
* Process and transform data inside workflows
* Automate CRM, notifications, reporting, and business operations
* Connect LLMs and AI services to existing applications
* Build scheduled and event-driven workflows
* Self-host automation while keeping control of your data

## n8n vs Other Workflow Automation Platforms

| Platform         | Self-Hosted      | Visual Workflows | Custom Code                  | AI Automation | Dedicated Task Execution | Best Fit                                            |
| ---------------- | ---------------- | ---------------- | ---------------------------- | ------------- | ------------------------ | --------------------------------------------------- |
| **n8n**          | ✅ Yes            | ✅ Yes            | ✅ Strong                     | ✅ Yes         | ✅ Task Runners           | Developers, APIs, AI workflows, advanced automation |
| **Zapier**       | ❌ Primarily SaaS | ✅ Yes            | ⚠️ Limited compared with n8n | ✅ Yes         | ❌ Managed internally     | Fast SaaS integrations and business automation      |
| **Make**         | ❌ Primarily SaaS | ✅ Yes            | ✅ Supported                  | ✅ Yes         | ❌ Managed internally     | Visual automation and complex business scenarios    |
| **Activepieces** | ✅ Yes            | ✅ Yes            | ✅ Extensible                 | ✅ Yes         | Architecture differs     | Open-source-oriented workflow automation            |

n8n is particularly well suited to technical teams that need flexible workflow logic, API integrations, custom code, AI automation, and control over where their automation infrastructure runs.

## Dependencies for n8n with Task Runners Hosting

* **n8n Main** — workflow editor, API, webhooks, scheduling, and orchestration
* **n8n Task Runners** — dedicated external execution environment for supported Code node tasks
* **PostgreSQL** — persistent relational database
* **Railway Private Networking** — communication between Main, Runners, and PostgreSQL
* **Shared Runner Authentication Token** — securely authenticates Task Runners with the n8n task broker
* **n8n Encryption Key** — protects stored credentials and encrypted application data

### Deployment Dependencies

* n8n Documentation: https://docs.n8n.io/
* n8n Task Runners: https://docs.n8n.io/hosting/configuration/task-runners/
* Task Runner Environment Variables: https://docs.n8n.io/hosting/configuration/environment-variables/task-runners/
* n8n Database Configuration: https://docs.n8n.io/deploy/host-n8n/configure-n8n/choose-n8ns-database
* n8n Docker Deployment: https://docs.n8n.io/deploy/host-n8n/install-options/install-with-docker
* Railway n8n Guide: https://docs.railway.com/guides/n8n
* Railway Private Networking: https://docs.railway.com/networking/private-networking

### Implementation Details

This template uses **external Task Runner mode**.

```text
                    ┌──────────────┐
                    │    Users     │
                    └──────┬───────┘
                           │
                           ▼
                    ┌──────────────┐
                    │   n8n Main   │
                    │ UI / API /   │
                    │ Webhooks     │
                    └──────┬───────┘
                           │
               ┌───────────┴────────────┐
               │                        │
               ▼                        ▼
       ┌──────────────┐         ┌──────────────┐
       │ PostgreSQL   │         │ Task Broker  │
       │ Persistent   │         │    :5679     │
       │ Data         │         └──────┬───────┘
       └──────────────┘                │
                                       ▼
                               ┌──────────────┐
                               │ Task Runners │
                               │ n8nio/runners│
                               └──────────────┘
```

The Main service runs n8n using PostgreSQL as its database backend and exposes the Task Runner broker over Railway's private network.

The Runners service uses the official:

```text
n8nio/runners
```

container image and connects privately to the task broker running on the Main service.

A shared `N8N_RUNNERS_AUTH_TOKEN` is used to authenticate communication between n8n and its external Task Runners.

This architecture intentionally does not use:

```text
Redis
n8n Worker
EXECUTIONS_MODE=queue
```

Task Runners and Queue Mode solve different problems. Task Runners provide a separate execution environment for supported tasks such as Code node execution, while Queue Mode distributes complete workflow executions across n8n workers using Redis.

This makes the template a useful middle ground between a basic single-container n8n deployment and a larger Queue Mode deployment with Redis and multiple workers.

## Why Use External Task Runners?

| Basic n8n                                         | n8n with Task Runners                                |
| ------------------------------------------------- | ---------------------------------------------------- |
| Code tasks execute alongside the main application | Code tasks can execute in dedicated runner processes |
| Simpler infrastructure                            | Better process separation                            |
| Good for lightweight deployments                  | Better suited for workflows using Code nodes         |
| Main instance handles more responsibilities       | Dedicated runners handle supported task execution    |
| Fewer services                                    | More controlled execution architecture               |

External Task Runners are particularly useful when workflows rely heavily on custom JavaScript or Python logic while keeping the main n8n application process focused on workflow orchestration.

## Why Deploy n8n with Task Runners 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 with Task Runners 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.


## Similar templates

- [N8N Main + Worker](https://railway.com/deploy/n8n-main-worker) — Deploy and Host N8N with Inactive worker.
- [Evolution API with n8n](https://railway.com/deploy/evolution-api-with-n8n) — [Jul'26] WhatsApp automation platform using Evolution API, n8n & PostgreSQL
- [Postgres Backup](https://railway.com/deploy/postgres-s3-backups) — Cron-based PostgreSQL backup to bucket storage

Open this page in a browser: https://railway.com/deploy/n8n-with-task-runners
