---
title: "Deploy N8N"
description: "Deploy n8n with Postgres."
category: "Automation"
url: https://railway.com/deploy/n8n-5
---

# Deploy N8N

Deploy n8n with Postgres.

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

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

- **Creator:** darseen
- **Category:** Automation

## Template content

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

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

### n8n https://devicons.railway.com/i/n8n.svg

- **Image:** n8nio/n8n:2.40.7
- **Start command:** `sh -c 'test "$(stat -c %U /home/node/.n8n)" = node || chown -R node:node /home/node/.n8n; export HOME=/home/node; exec su -p -s /bin/sh node -c "exec /sbin/tini -- /docker-entrypoint.sh"'`
- **Health check:** /healthz/readiness
- **Public domain:** Yes

## Documentation

# Deploy and Host N8N on Railway

**This variant: n8n with Postgres.** One n8n instance on a volume, backed by Railway's managed Postgres. 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

This template deploys two services: `n8n` (the editor, API, triggers and executions in one process) and `Postgres` (workflows, credentials and execution history). n8n is pinned to 2.40.7.

The first boot runs n8n's database migrations, which takes about a minute before the healthcheck on `/healthz/readiness` turns green. Then open the public URL and **create the owner account right away**: the first visitor to an unclaimed instance becomes its owner.

The `n8n` service keeps a volume at `/home/node/.n8n` for binary files from executions and for community nodes you install from the UI. The volume also means Railway never runs two copies of n8n side by side during a redeploy, so Schedule triggers do not fire twice.

## Common Use Cases

- Replace Zapier or Make: sync CRMs, spreadsheets, email and Slack without per-task pricing
- Build AI agents and chatbots with the built-in LangChain nodes and any LLM provider
- Receive webhooks from Stripe, GitHub or your own apps and run backend logic on them

## Dependencies for N8N Hosting

- Nothing to bring. Every secret (Postgres password, n8n encryption key) is generated at deploy time.
- Optional: API keys for the services your workflows connect to, added later as n8n credentials.

### Deployment Dependencies

- n8n: https://github.com/n8n-io/n8n
- Docker image: https://hub.docker.com/r/n8nio/n8n
- Self-hosting docs: https://docs.n8n.io/hosting/

### Implementation Details 

- **Other N8N variants.** This creator also publishes n8n with queue-mode workers, with workers plus webhook processors, a single-service SQLite version, and a version with external task runners for Python Code nodes.
- **Back up `N8N_ENCRYPTION_KEY`.** It encrypts every credential in Postgres. Lose it and those credentials cannot be decrypted, even with a database backup.
- **Custom domain.** After adding one, set `N8N_EDITOR_BASE_URL` and `N8N_WEBHOOK_URL` on `n8n` to `https://your-domain` so webhook and OAuth URLs use it.
- **Volume permissions.** Railway mounts volumes owned by root. The start command runs as root only long enough to hand `/home/node/.n8n` to the `node` user, then starts n8n as `node`:

  ```sh
  test "$(stat -c %U /home/node/.n8n)" = node || chown -R node:node /home/node/.n8n
  export HOME=/home/node; exec su -p -s /bin/sh node -c "exec /sbin/tini -- /docker-entrypoint.sh"
  ```

- **Code nodes** run on n8n's internal JavaScript task runner. Python Code nodes need external task runners, which the task-runners variant provides.
- **Upgrading.** Change the image tag on `n8n` to a newer `n8nio/n8n` version and redeploy; migrations run on boot.
- **Execution history** is pruned after 14 days or 10,000 executions (`EXECUTIONS_DATA_MAX_AGE`, `EXECUTIONS_DATA_PRUNE_MAX_COUNT`), which keeps the Postgres volume from growing without bound.

## 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.



## 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-5
