---
title: "Deploy n8n"
description: "n8n on Postgres, your owner account created at deploy"
category: "Automation"
url: https://railway.com/deploy/n8n-9
---

# Deploy n8n

n8n on Postgres, your owner account created at deploy

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

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

- **Creator:** Dektion Studio
- **Category:** Automation
- **Total deploys:** 3

## Template content

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

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

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

- **Source:** dektionstudio/railway-template-images
- **Health check:** /healthz
- **Public domain:** Yes

## Documentation

# Deploy and Host n8n on Railway

[n8n](https://github.com/n8n-io/n8n) is a workflow automation tool: visual flows with hundreds of integrations, webhooks, schedules, code steps and AI agent nodes.

This template runs the official image (2.40.7) on Postgres, with n8n's folder on a volume for community nodes and binary data.

## About Hosting n8n

A fresh n8n asks whoever opens it first to create the owner account. On a public URL that can be anyone, and most templates leave it open until you get there. This one sets the owner up for you: the deploy form asks for your email, a password is generated into `N8N_OWNER_PASSWORD`, and a start step creates the owner once n8n is ready, then signs in to confirm it. Open `N8N_URL` and sign in with that email and password.

My first version of that step fired as soon as `/healthz` answered, which is while the database migrations are still running, and in my test the owner it created didn't stick: a second setup request from another address then succeeded. The step now waits for `/healthz/readiness` and retries until signing in works.

Before publishing I tested the final version on a fresh deploy. The start step reported the owner as set up, a setup request from another address was refused with "Instance owner already setup", and the owner signed in with the owner role. A workflow with a webhook trigger, created and activated through the API, ran with status success when I called the webhook. After a restart the workflow was still active and its webhook still answered.

## Common Use Cases

- Connect your apps with flows triggered by webhooks, schedules or app events
- Build AI agent workflows that call models and tools, with credentials stored encrypted

## Dependencies for n8n Hosting

Nothing beyond the template: Postgres is included. Integrations need their own credentials, added in n8n.

### Deployment Dependencies

- n8n: https://github.com/n8n-io/n8n
- Docs: https://docs.n8n.io/hosting/
- Image: `n8nio/n8n:2.40.7`
- The wrapper this template builds: https://github.com/dektionstudio/railway-template-images/tree/main/n8n

### Implementation Details

```
N8N_OWNER_EMAIL / N8N_OWNER_PASSWORD   # owner account, set up on first start
N8N_ENCRYPTION_KEY                     # generated; encrypts stored credentials, keep it
WEBHOOK_URL=https:///  # change it when you add a custom domain
DB_TYPE=postgresdb, DB_POSTGRESDB_*    # Postgres over the private network
N8N_RUNNERS_ENABLED=true               # Code nodes run in task runners
```

The container starts as root only to hand the volume to n8n's `node` user; the image has no package manager, so the start step drops privileges through Node itself. To upgrade, set `N8N_VERSION` (an image tag) on the n8n service.

n8n logs that internal task runner mode is deprecated. It still works in 2.40.7; upstream recommends a separate runner process for larger setups.

Idle, n8n used 0.40 GB of RAM and Postgres 0.14 GB.

## Why Deploy n8n on Railway?

Webhooks need a public HTTPS address that stays up, and here it's yours from the first minute with nobody else able to claim the owner account. Both services come to about $5 a month in RAM at idle.


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