---
title: "Deploy n8n Gmail"
description: "Gmail labels, replies and routing with n8n"
category: "Automation"
url: https://railway.com/deploy/n8n-gmail
---

# Deploy n8n Gmail

Gmail labels, replies and routing with n8n

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

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

- **Creator:** onepush
- **Category:** Automation

## Template content

### n8n

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

### Redis https://cdn.sanity.io/images/sy1jschh/production/0ce0bfdcfbdbf69662b1116671f97c2dd788b655-157x157.svg

- **Image:** redis:8.2
- **Start command:** `/bin/sh -c "rm -rf $RAILWAY_VOLUME_MOUNT_PATH/lost+found/ && exec docker-entrypoint.sh redis-server --requirepass $REDIS_PASSWORD --save 60 1 --dir $RAILWAY_VOLUME_MOUNT_PATH"`

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

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

### n8n-worker

- **Image:** n8nio/n8n:2.36.8
- **Start command:** `n8n worker`
- **Health check:** /healthz

## Documentation

# Deploy and Host self hosted n8n Gmail (Open-Source Gmail Automation) on Railway

n8n Gmail is a queue-mode n8n deployment for Gmail labels, auto-replies, inbox routing, and handoffs to Slack or Notion. Workers process mailbox volume while the editor stays free for building flows.


## About Hosting n8n Gmail open-source software on Railway (self hosted n8n template)

n8n Gmail is a self-hosted automation stack built on the n8n workflow engine for Gmail inbox operations. Deploy the n8n Community Edition (fair-code) on Railway with PostgreSQL and Redis Bull queue, then connect Gmail via OAuth2. Automate labels, auto-replies, routing to Slack/Notion, and multi-step inbox workflows without vendor lock-in.

This Railway template provisions two services from the official `n8nio/n8n:2.36.8` Docker image: an editor (port 5678) and a worker (`n8n worker` command). Both share PostgreSQL and Redis. Queue mode ensures long-running Gmail operations (rate limits, attachments, webhooks) execute asynchronously on the worker while the editor stays responsive. The Gmail node supports OAuth2, labels, drafts, threads, and sending natively—no Apps Script needed.

## Why Deploy n8n Gmail, the Zapier alternative on Railway (Railway Free Trial)

Zapier charges per task; Gmail workflows burn tasks fast. A single email labeled, summarized, routed to Slack, and logged to Notion consumes 4+ tasks. n8n Gmail on Railway costs only infrastructure—no per-execution fees. Community Edition is fair-code, auditable, and unlimited.

Railway's $5 free trial (GitHub signup) lets you test the full queue-mode stack. After trial, typical cost is $10–$25/month, less than n8n Cloud Starter ($24/month for 2,500 executions). For Gmail-heavy teams, self-hosted economics win.

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

### Railway vs Other Hosting Providers and VPS for n8n Gmail self hosting

| Provider | Setup Complexity | Queue Mode Support | Monthly Cost | Gmail Automation Fit |
|---|---|---|---|---|
| DigitalOcean | Manual Docker Compose; manage Postgres/Redis | Manual | $12–$48+ | Workable but high ops burden |
| AWS | High; ECS, RDS, ElastiCache | Complex IAM/VPC | $30–$100+ | Overkill for most |
| Hetzner | Moderate; VPS + manual services | Self-managed | $8–$30 | Cost-effective but no integrated deploy |
| Railway | One-click template; Postgres/Redis auto | Native | $10–$25 | Purpose-built |

Railway eliminates operational tax: no manual Docker, Postgres, Redis, reverse proxy, or SSL setup.

## Common Use Cases for hosted n8n Gmail

- **Label management**: Apply labels based on sender, subject, attachments, or thread history.
- **Contextual auto-replies**: Send templated replies with data from CRM, Calendly, etc.
- **Routing to Slack/Notion**: Extract email fields, post to Slack, create Notion rows.
- **Inbox triage**: Branch on keywords/sentiment; escalate via Slack @mentions, SMS, or archive.
- **Attachment processing**: Download, parse, upload to Drive/S3, extract data, notify.
- **Scheduled digests**: Summarize unread emails daily and post to Slack or send email.

## Dependencies for n8n Gmail Docker hosted on Railway

The stack uses official n8nio/n8n with Postgres and Redis Bull so Gmail trigger workflows can run in queue mode with durable credentials and execution history.


### Deployment Dependencies for Managed n8n Gmail Service (Gmail Automation)

Four Railway services: editor (port 5678), worker (`n8n worker`), PostgreSQL, Redis (Bull queue). Key env vars: `EXECUTIONS_MODE=queue`, `DB_TYPE=postgresdb`, Redis connection string, volume at `/home/node/.n8n`, `WEBHOOK_URL`, `N8N_PROXY_HOPS=1`, `N8N_ENCRYPTION_KEY` (never lose it), `EXECUTIONS_DATA_PRUNE=true`.

### Implementation Details for n8n Gmail (Using n8n official docker image)

Both services use `n8nio/n8n:2.36.8`. Editor exposes port 5678; worker has no public port. Configure Gmail OAuth2 in editor. Queue mode: editor enqueues, worker executes, results stored in PostgreSQL. Bull queue retries failed jobs.

## How does n8n Gmail compare against other Email Automation platforms

This Railway listing positions queue-mode n8n as a self-hosted alternative to hosted email automation tools when you need unlimited Gmail workflow runs and full data control.


### n8n Gmail vs Zapier (Zapier Alternative)

Zapier bills per task; n8n bills flat infrastructure. n8n supports branching, loops, error handling natively. Gmail node exposes more operations (threads, drafts, labels, advanced search).

### n8n Gmail vs Make (Make Alternative)

Make uses operations-based pricing; complex Gmail workflows consume ops fast. n8n queue mode handles long-running operations without timeouts. Sub-workflows and error handling are more robust.

### n8n Gmail vs Power Automate (Power Automate Alternative)

Power Automate's Gmail connector relies on polling, adds latency, and ties to Microsoft 365 licensing. n8n is Gmail-native with OAuth2 push webhooks, labels, threads.

### n8n Gmail vs Pipedream (Pipedream Alternative)

Pipedream requires more code, pricing based on credits/compute. n8n visual nodes, predictable infrastructure cost, data stays in your Railway project.

## How to use n8n Gmail (the OSS Gmail Automation)?

1. Connect Gmail via OAuth2 in Credentials panel.
2. Add Gmail Trigger node (Message Received) with optional search query.
3. Add action nodes: Gmail (label/reply), Slack, Notion, IF, etc.
4. Test with Execute Workflow, then activate. Queue mode runs on worker; monitor in editor.

## How to self host n8n Gmail on other VPS Services (n8n Gmail self hosting guide)

On a raw VPS you must deploy editor, worker, Postgres, Redis, set WEBHOOK_URL for OAuth callbacks, and never lose N8N_ENCRYPTION_KEY or Gmail credentials will not decrypt.


### Clone the Repository

Create `docker-compose.yml` with four services: n8n-editor, n8n-worker (command `n8n worker`), postgres, redis. Use image `n8nio/n8n:2.36.8`.

### Install Dependencies

Install Docker and Docker Compose. No other system deps. Open port 5678 and SSH.

### Configure Environment Variables

Set `EXECUTIONS_MODE=queue`, `DB_TYPE=postgresdb`, Postgres/Redis connection strings, `N8N_ENCRYPTION_KEY` (generate with `openssl rand -hex 32`), `WEBHOOK_URL`, `N8N_PROXY_HOPS=1`, volume `/home/node/.n8n`.

### Start the n8n Gmail Application

Run `docker compose up -d`. Access editor at `http://server-ip:5678`. Set up owner account, Gmail OAuth2. Use reverse proxy with SSL for production.

## Official Pricing of n8n Gmail (n8n Gmail pricing)

n8n Community Edition is free to self-host (fair-code). n8n Cloud Starter ~$24/month for 2,500 executions. Railway self-hosted stack: $10–$25/month, no per-execution fees. $5 free trial on GitHub signup.

## n8n Gmail cloud vs self hosted comparison (Pricing, features, costs, and more)

Self-hosting Gmail automation on Railway typically costs less at volume than cloud plans that bill per task or execution, especially for label routing and reply bots.


### Monthly cost of self hosting n8n Gmail on Railway

Editor/worker: 512MB–1GB RAM each, 0.5–1 vCPU. Postgres/Redis: 512MB each. Total $10–$25/month. Scale worker horizontally for more throughput. Compare: n8n Cloud $24/2,500 exec; Zapier $19.99/750 tasks.

### System Requirements for Hosting n8n Gmail on a VPS

Minimum 2GB RAM, 2 vCPUs, 20GB disk. High volume: 4GB RAM, 4 vCPUs, multiple workers. Queue mode scales horizontally.

## Frequently Asked Questions (FAQs)

These FAQs cover queue mode, Gmail OAuth, encryption keys, and when to use the single-node listing instead of workers.


### Can I use SQLite instead of PostgreSQL for n8n Gmail queue mode?

No. SQLite cannot run queue mode. PostgreSQL required for concurrent editor/worker access. Railway template provisions it automatically.

### How do I connect my Gmail account to n8n?

Use Gmail OAuth2 credential in editor. Personal Gmail: standard OAuth2. Workspace: service account for domain-wide delegation.

### What happens if I lose my N8N_ENCRYPTION_KEY?

All encrypted credentials (Gmail, Slack, Notion) become unreadable. Re-authenticate everything. Store key securely.

### Does the Community Edition support SSO for team access?

No. Community Edition has no SSO or user management. Single owner account. Enterprise edition required for SSO.

### How many Gmail messages can n8n process per day?

No hard limit. Limited by worker resources and Google API rate limits (250 quota units/sec/user). Single worker handles thousands/day; add workers for more.

### Can I run this alongside the cheapest n8n without queue mode?

Yes. For lightweight automation, deploy the [cheapest n8n without queue mode](https://railway.com/deploy/n8n) (single container, SQLite). But it cannot use `EXECUTIONS_MODE=queue` and may become unresponsive during long Gmail operations. Queue-mode template is recommended for production.
Queue-mode workers keep n8n Gmail executions off the editor so webhooks stay fast under load.
Queue-mode workers keep n8n Gmail executions off the editor so webhooks stay fast under load.
Queue-mode workers keep n8n Gmail executions off the editor so webhooks stay fast under load.
Queue-mode workers keep n8n Gmail executions off the editor so webhooks stay fast under load.
Queue-mode workers keep n8n Gmail executions off the editor so webhooks stay fast under load.
Queue-mode workers keep n8n Gmail executions off the editor so webhooks stay fast under load.
Queue-mode workers keep n8n Gmail executions off the editor so webhooks stay fast under load.
Queue-mode workers keep n8n Gmail executions off the editor so webhooks stay fast under load.

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