---
title: "Deploy Twenty Gmail Sync"
description: "Sync Gmail and Google Calendar into Twenty CRM"
category: "Other"
url: https://railway.com/deploy/deploy-twenty-crm-with-gmail-sync
---

# Deploy Twenty Gmail Sync

Sync Gmail and Google Calendar into Twenty CRM

**[Deploy Twenty Gmail Sync on Railway](https://railway.com/template/deploy-twenty-crm-with-gmail-sync)**

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

- **Creator:** onepush
- **Category:** Other

## Template content

### twenty-worker

- **Image:** twentycrm/twenty:v2.48.0@sha256:43fab4bffacdcd63ff3c9257b7f8985a4424d81e9eb43982b9c16a841d555e52
- **Start command:** `/app/entrypoint.sh yarn worker:prod`

### Postgres

- **Image:** ghcr.io/railwayapp-templates/postgres-ssl:16.15@sha256:34c3e49e7ed2aaef6c575fb23bb37b878007e97752d3bf27ccb550046f893ca7

### twenty

- **Image:** twentycrm/twenty:v2.48.0@sha256:43fab4bffacdcd63ff3c9257b7f8985a4424d81e9eb43982b9c16a841d555e52
- **Health check:** /healthz
- **Public domain:** Yes

### Redis

- **Image:** redis:8.2.10@sha256:47670742d7924adbcdb404d1288b6327815b23141969c0939b8e5d61f78c2634
- **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 --maxmemory-policy noeviction --bind '* -::*'"`

## Documentation

# Deploy and Host self hosted Twenty Gmail Sync (Open-Source CRM) on Railway

This template runs Twenty v2.48.0 with a worker, Postgres and Redis, so Gmail threads and Google Calendar events land on person and company records. Made for small sales teams leaving per-seat CRMs.

## About Hosting Twenty Gmail Sync open-source software on Railway (self hosted Twenty CRM Gmail sync template)

Emails, calendar events and OAuth tokens stay in your own Postgres volume, encrypted with the ENCRYPTION_KEY you generate at deploy. This template runs Twenty v2.48.0 with its worker, Postgres 16 and Redis 8.2.

## Why Deploy Twenty Gmail Sync, the HubSpot alternative on Railway (Railway Free Trial)

HubSpot bundles email sync into paid seats, and you rent the whole stack with it. Self hosted Twenty keeps contacts, threads and calendar events in your own Postgres, and Railway's $5 trial covers the first look.

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 Twenty Gmail Sync 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 Twenty Gmail Sync self hosting

The comparison that matters here is who owns the OAuth plumbing and the worker cron jobs, not raw compute pricing.

| Provider | What You Get with Railway | What You Get with the Other Provider |
| --- | --- | --- |
| DigitalOcean | Four wired services, one redeploy | Droplets, manual compose, your own TLS |
| AWS | Managed volumes and variables | ECS or EC2 plus IAM and ALB work |
| Hetzner | Same template, managed domain | Cheap VMs you patch and proxy |

## Common Use Cases for hosted Twenty Gmail Sync

- **Every thread on the company record:** once a rep connects Gmail, synced messages attach to the matching company and person, so a handover does not depend on someone's inbox.
- **Meetings on the person timeline:** Google Calendar events land next to emails, which makes the last conversation and the next call easy to see before you dial.
- **Inbound leads out of the shared mailbox:** once the worker imports a rep's messages, replies from prospects show up on their records, not just in one inbox.
- **A shared team view of customer email:** per-account visibility settings decide whether teammates see metadata or full content, and you can exclude personal addresses.
- **Microsoft 365 shops:** the same timeline works with Microsoft Graph when you set the Microsoft provider variables and each user has a license.

## Dependencies for Twenty Gmail Sync Docker hosted on Railway

Four services ship here: twenty (v2.48.0 server and web, port 3000, health check /healthz, volume /app/packages/twenty-server/.local-storage), twenty-worker (same image, runs `yarn worker:prod`), Postgres 16, and Redis 8.2, both with volumes.

### Deployment Dependencies for Managed Twenty Gmail Sync Service (CRM)

You need a Google Cloud project with the Gmail API, Google Calendar API and People API enabled, plus an OAuth 2.0 web client whose redirect URIs are https://your-domain/auth/google/redirect and https://your-domain/auth/google-apis/get-access-token.

### Implementation Details for Twenty Gmail Sync (Using Twenty official docker image)

The twenty service runs migrations on start (DISABLE_DB_MIGRATIONS=false) and registers cron jobs (DISABLE_CRON_JOBS_REGISTRATION=false); the worker sets both true and executes messages-import, message-list-fetch, calendar-event-list-fetch, calendar-events-import and ongoing-stale.

## How does Twenty Gmail Sync compare against other CRMs with email sync

### Twenty vs HubSpot (HubSpot Alternative)

- **Who owns the OAuth client:** You do. A redirect_uri_mismatch is yours to fix, and Gmail's restricted scopes may need Google verification before outside users connect.
- **Visibility control:** Per-account settings cap what teammates see, from metadata only to full content, and you can exclude personal addresses or whole domains.
- **Where HubSpot wins:** Its email sync, sequences and shared inbox need no Google Cloud project from you.

### Twenty vs Attio (Attio Alternative)

- **Sync plumbing:** Attio runs mail sync for you; here twenty-worker cron jobs import messages and events, and nothing syncs while the worker is down.
- **Open source:** You get AGPL-3.0 code, your own Postgres, and the option to fork when a sync behavior annoys you.
- **Where Attio wins:** A polished, hosted collaborative data model with far less ops work.

### Twenty vs Pipedrive (Pipedrive Alternative)

- **Breadth:** Pipedrive is pipeline-first, while Twenty pairs Gmail and Calendar sync with custom objects, views and workflows.
- **Setup honesty:** Microsoft 365 users can connect instead of Google, but you still own the Azure app registration and the same variable wiring.
- **Where Pipedrive wins:** Fast, packaged onboarding and a mature mobile app.

### Twenty vs Salesforce (Salesforce Alternative)

- **Seat math:** Self-hosted Twenty has no per-user license line; Railway compute is the bill, easier to predict for a small team.
- **Extensibility:** You get GraphQL and REST APIs, webhooks and role permissions without buying an add-on.
- **Where Salesforce wins:** A huge partner ecosystem, service and marketing clouds, and support SLAs.

## How to use Twenty Gmail Sync (the OSS CRM)?

1. Create a Google Cloud project, then enable the Gmail API, Google Calendar API and People API.
2. On the OAuth consent screen, add your users as test users.
3. Create a Web client; redirect URIs: https://your-domain/auth/google/redirect and https://your-domain/auth/google-apis/get-access-token.
4. In Settings > Admin Panel > Configuration Variables set MESSAGING_PROVIDER_GMAIL_ENABLED=true, CALENDAR_PROVIDER_GOOGLE_ENABLED=true, AUTH_GOOGLE_CLIENT_ID, AUTH_GOOGLE_CLIENT_SECRET, AUTH_GOOGLE_CALLBACK_URL and AUTH_GOOGLE_APIS_CALLBACK_URL.
5. Each user connects Google in Settings > Accounts; open a person record and confirm emails appear.

If nothing syncs, check that twenty-worker is running.

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

A 2 GB Linux box with Docker Compose runs this stack; more RAM helps during migrations.

### Clone the Repository

You only need two files from packages/twenty-docker in the official repo.

```
mkdir twenty
cd twenty
curl -o docker-compose.yml https://raw.githubusercontent.com/twentyhq/twenty/main/packages/twenty-docker/docker-compose.yml
curl -o .env https://raw.githubusercontent.com/twentyhq/twenty/main/packages/twenty-docker/.env.example
```

### Install Dependencies

Install Docker Engine and the Compose plugin.

```
docker compose version
```

### Configure Environment Variables

In .env set TAG=v2.48.0, SERVER_URL=https://your-domain, PG_DATABASE_PASSWORD and APP_SECRET (openssl rand -base64 32). STORAGE_TYPE=local is the default. The Google OAuth pair goes in the Admin Panel after first login.

### Start the Twenty Gmail Sync Application

```
docker compose up -d
```

Open your-domain, sign up, connect Gmail in Settings > Accounts, and check that a person record picks up mail.

On Railway the domain, TLS, Postgres, Redis and worker come provisioned, so you only paste the OAuth client pair.

## Official Pricing of Twenty Gmail Sync (Twenty pricing)

Twenty itself is free: the code is AGPL-3.0, and nothing in Gmail or Calendar sync sits behind a license fee. You pay for infrastructure, not seats.

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

Self hosting is free under AGPL-3.0, and the only recurring bill is the infrastructure. Twenty Cloud bills per user on Pro and Organization plans, which gets expensive once a small sales team wants Gmail and Calendar sync for everyone.

### Monthly cost of self hosting Twenty Gmail Sync on Railway

A small-team deployment runs about $10-25 per month for all four services: twenty, twenty-worker, Postgres 16 and Redis 8.2. The worker is not optional here, so budget for it. Google Cloud OAuth and the Gmail API are free at normal volumes.

### System Requirements for Hosting Twenty Gmail Sync on a VPS

Upstream suggests at least 2 GB RAM. You need Postgres 16 and Redis 8.2 beside the app, plus disk for the local-storage volume and synced email metadata. Add headroom for the worker, since sync and cron jobs run there.

## Frequently Asked Questions (FAQs)

### Which redirect URIs do I need in Google Cloud?

Both: https://your-domain/auth/google/redirect for SSO and https://your-domain/auth/google-apis/get-access-token for the Gmail and Calendar integration. A mismatch between these and the values in Twenty is what throws redirect_uri_mismatch.

### Why does Google say my app is unverified?

The scopes Twenty requests include gmail.readonly, which Google classifies as restricted, so the consent screen shows a warning until you complete verification.

### Do I set the Google variables on the worker too?

In the default database config mode, no. Only env-only mode needs them on both services plus a redeploy.

### Why are no emails syncing?

Usually twenty-worker is down, since the server registers the cron jobs but the worker runs them. Check its logs, then run yarn command:prod cron:messaging:messages-import from the worker shell to kick the import.

### Can teammates read my synced email?

Only as far as your per-account visibility setting allows, from metadata up to full content. You can also exclude personal addresses or whole domains from syncing.

### Does Outlook work instead of Gmail?

Yes, if you configure the Microsoft variables and your users hold a Microsoft 365 license. Graph permissions include Mail.ReadWrite, Calendars.ReadWrite and offline_access for token refresh.


## Similar templates

- [Rocky Linux](https://railway.com/deploy/rocky-linux) — Hosted Rocky Linux 9 workspace with SSH and persistent storage. 🚀
- [Foundry Virtual Tabletop](https://railway.com/deploy/X5tR6G) — A Self-Hosted & Modern Roleplaying Platform
- [Letta Code Remote](https://railway.com/deploy/letta-code-remote) — Run a Letta Code agent 24/7. No inbound ports, just deploy.

Open this page in a browser: https://railway.com/deploy/deploy-twenty-crm-with-gmail-sync
