---
title: "Deploy n8n 2"
description: "n8n [Nov '26] (Workflows/Integrations/AI Agents) Self Host on Postgres"
category: "Automation"
url: https://railway.com/deploy/n8n-2-1
---

# Deploy n8n 2

n8n [Nov '26] (Workflows/Integrations/AI Agents) Self Host on Postgres

**[Deploy n8n 2 on Railway](https://railway.com/template/n8n-2-1)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/n8n-2-1/manifest.json

- **Creator:** ninja
- **Category:** Automation
- **Total deploys:** 3

## Template content

### Postgres https://cdn.simpleicons.org/postgresql

- **Image:** ghcr.io/railwayapp-templates/postgres-ssl:18
- **Start command:** `/usr/bin/tini -g -- /usr/local/bin/wrapper.sh postgres -p 5432 -c listen_addresses=*`

### n8n https://cdn.simpleicons.org/n8n

- **Image:** n8nio/n8n:stable
- **Public domain:** Yes

## Documentation

# Deploy and Host n8n 2 on Railway

n8n is a workflow automation platform. You connect apps, APIs and AI models into workflows that run on triggers, on schedules, or when you call them. Version 2 is the stable line: the newest non-prerelease 2.x release, pinned to an exact tag.

This is the stable-line sibling of the n8n 3 template. The two differ by pin only: same two services, same variables, same regular-mode shape. n8n 3 is the breaking next major, still in pre-release; n8n 2 is the line for users who want the current stable release.

## About Hosting n8n 2

This template runs the official n8n image at an exact pinned version, stated on this page and in the repo, with a Postgres database. Two services:

- **n8n**: the editor, the API and workflow execution. The only service with a public URL.
- **Postgres**: workflows, credentials and execution history, on their own volume. This is the state that matters, and it survives redeploys. Local files written inside the n8n container do not.

The pin matters. A redeploy gives you the same n8n you tested, never a surprise upgrade. Version bumps are deliberate, retested, and noted in the repo.

## Why Deploy

- You get n8n 2 itself, not an unnamed version. The page and the repo state the exact tag.
- The parts people usually get wrong are already set: the encryption key is generated, the public address is wired to your Railway domain, and execution data pruning is on, so the database does not grow without limit.
- It is a small, honest shape: two services, regular mode, no Redis, no worker fleet to feed. You pay for what this page describes.

## What is included

- n8n at the pinned tag (see Status below), from the official image `n8nio/n8n`
- Postgres 18 with SSL, from Railway's own Postgres image, on a volume
- A generated encryption key for stored credentials
- Webhook and OAuth callback addresses wired to your Railway domain
- Task runners, on by default in n8n 2 (JavaScript Code nodes; the Python runner is unverified on this pin)
- Execution data pruning: 14 days, at most 10,000 executions

## After you deploy

1. Wait until both services are green.
2. Open the n8n service's public URL.
3. Create the owner account. The first account created owns the instance, so do this promptly: the setup page is open to anyone who finds the URL first.
4. Open the **n8n** service in Railway, go to **Variables**, and copy `N8N_ENCRYPTION_KEY` somewhere safe outside Railway. The warning below explains why this cannot wait.
5. Build your first workflow, or import one.

## Back up the encryption key

Credentials you store in n8n are encrypted with `N8N_ENCRYPTION_KEY`, generated for you at deploy time. Keep a copy of that value somewhere safe, outside Railway. Never change it: if it changes or is lost, every stored credential becomes unreadable, and a database backup cannot recover them, because the backup holds the same encrypted data and the key is not in it.

## Coming from n8n 1.x

n8n 2 is the current stable line, so deploying it fresh involves no breaking upgrade. If you are moving an existing 1.x instance to this template, back up your database and your current encryption key first. Support for 1.x ends on 31 December 2026, and 2.x keeps security fixes for 12 months after 3.0 stable ships. This template is a fresh install; it does not migrate an existing database. The sibling n8n 3 template is the path when you are ready for the next major.

## Trade-offs, stated plainly

- **Regular mode only.** No queue mode, no workers, no Redis. One process serves the editor and runs every execution. That is the right default for most self hosted instances. Heavy parallel loads are the case for a worker setup, and this template does not pretend to be one.
- **Local files do not persist.** Workflows, credentials and execution history live in Postgres and survive redeploys. Files a workflow writes inside the n8n container are gone at the next redeploy; send anything you need to keep to storage outside the container.
- **No live test on this pin yet.** See Status below.
- **You run it.** Database backups, the encryption key backup, and watching disk use past the pruning window are yours.

## Status

This template uses the floating **stable** tag (n8nio/n8n:stable), so new deploys always get the newest stable 2.x release. As of 2026-11-30 that is **2.49.9**. The version you are getting is always the newest stable 2.x release at deploy time; the repo records the version it resolved to on the last live test.

## Common Use Cases

- Hand offs between apps: CRM updates, lead alerts, invoice filing
- Scheduled reports pulled from APIs into a sheet or a chat channel
- Webhook endpoints that glue services together
- AI workflows that summarize, classify and route messages with the model you choose

## Dependencies for n8n 2 Hosting

- Postgres (included)
- Nothing else. Model provider keys are optional, and only needed for AI nodes.

### Deployment Dependencies

- [n8n repository](https://github.com/n8n-io/n8n)
- [n8n documentation](https://docs.n8n.io/)
- Template source: this repository

## 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) — Automate WhatsApp workflows with Evolution API, n8n, and Postgres.
- [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-2-1
