---
title: "Deploy AFFiNE [Updated Sep '26]"
description: "AFFiNE [Sep '26] (Self-Hosted Notion and Miro Alternative)"
category: "CMS"
url: https://railway.com/deploy/affine-open-source
---

# Deploy AFFiNE [Updated Sep '26]

AFFiNE [Sep '26] (Self-Hosted Notion and Miro Alternative)

**[Deploy AFFiNE [Updated Sep '26] on Railway](https://railway.com/template/affine-open-source)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/affine-open-source/manifest.json

- **Creator:** shruistic
- **Category:** CMS

## Template content

### affine https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/svg/affine-light.svg

- **Image:** ghcr.io/toeverything/affine:stable
- **Public domain:** Yes

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

- **Image:** redis:8.2.1
- **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"`

### pgvector https://devicons.railway.app/postgres

- **Image:** pgvector/pgvector:pg18
- **Start command:** `/bin/sh -c "unset PGPORT; docker-entrypoint.sh postgres --port=5432"`

## Documentation

# Deploy and Host AFFiNE Self-Hosted on Railway

AFFiNE is the open-source answer to Notion, but with a real infinite-canvas whiteboard built in as a first-class citizen alongside docs and databases, not a drawing tool bolted onto a doc editor. This template deploys its real 3-service architecture, verified live end-to-end.

## About Hosting AFFiNE Self-Hosted

Notion's Business plan runs $20/user/month, and even the Plus plan is $10/user/month, both billed per seat regardless of actual usage. A 10-person team on Business pays $200/month before any AI add-ons stack on top. AFFiNE self-hosted on Railway flips that entirely: a flat infrastructure cost regardless of team size, no per-seat charge at all.

The second reason is feature shape, not just price. Notion has no native whiteboard. AFFiNE ships one as a real workspace mode, an actual infinite canvas, not a drawing widget inside a doc, alongside its doc editor and database blocks, all in the same workspace.

## This Template Deploys AFFiNE's Real Architecture, and For Once, Nothing Broke

AFFiNE's own official Docker setup, fetched live from `.docker/selfhost/compose.yml` on GitHub, defines an app service, a Postgres database, and Redis, plus a separate one-shot migration container that has to finish before the app starts. This template mirrors the app/Postgres/Redis split, but handles that migration step differently, and better.

Every earlier template in this series that's hit a version of "one service needs another to finish first" has run into some flavor of race condition: Superset's worker and beat processes crash-looping until the web service's migrations landed, Libredesk's install step racing Postgres's network readiness. AFFiNE's own official compose solves this with a separate `affine_migration` container gated by `depends_on: condition: service_completed_successfully`, essentially the same shape of fix, just implemented as a second container instead of within one. Railway has a cleaner primitive for exactly this: `preDeployCommand`, a command guaranteed to run to completion on the *same* service instance before its actual start command begins. No separate container, no restart-policy retries needed, no eventual consistency. Using it here instead of translating the two-container pattern directly is what let this build get all 3 services healthy on the very first deploy, a genuine first for this template series, no crash logs to chase down this time.

One thing worth flagging proactively rather than discovering the hard way: `AFFINE_ADMIN_PASSWORD` has a real complexity requirement, confirmed directly from AFFiNE's own documentation, at least 1 uppercase letter, 2 digits, and 2 special characters. Given Libredesk's system password hit a nearly identical requirement and produced a genuinely misleading failure when unmet, this build used the same defensive fix from the start: a chained `${{secret()}}` expression that draws each required character class explicitly, guaranteeing the requirement by construction instead of hoping a single random draw happens to satisfy it.

## Common Use Cases

- **Teams replacing Notion to cut per-seat costs**: Flat infrastructure pricing instead of $10-20 per user per month.
- **Privacy-conscious individuals and teams**: Every doc, whiteboard, and database stays off third-party servers entirely.
- **Teams that actually use whiteboards, not just docs**: A real infinite-canvas whiteboard alongside docs, not a separate tool to subscribe to on top.
- **Knowledge bases mixing structured and unstructured content**: Database blocks live inside the same workspace as written docs, not a separate app.

## Dependencies for AFFiNE Self-Hosted Hosting

Just two backing services: a pgvector-enabled Postgres for all persistent data, docs, whiteboards, workspaces, and Redis for caching and background jobs. No separate search service, no separate file storage service, both fold into the same two.

### Deployment Dependencies

This template deploys 3 services total: the app, Postgres, and Redis. Lighter than most comparable all-in-one workspace tools while still covering the full doc, whiteboard, and database feature set.

### Reference Links

Official documentation: docs.affine.pro. Source and issue tracker: github.com/toeverything/AFFiNE. Official Docker images: `ghcr.io/toeverything/affine`.

### Implementation Details

The app runs `ghcr.io/toeverything/affine:stable`, matching AFFiNE's own official compose image tag exactly. Postgres uses `pgvector/pgvector:pg18`, bumped from the official compose's `pg16`, a low-risk version bump given pgvector's API stability. Database migrations and admin account creation run via `preDeployCommand` before the app starts serving traffic.

## How AFFiNE Compares to the Alternatives

Against Notion, the trade is infrastructure ownership for zero-setup convenience, same shape as every self-hosted alternative in this series. Notion requires nothing beyond a subscription; AFFiNE requires deploying 3 services (which this template does in one click) in exchange for zero per-seat fees and a whiteboard Notion simply doesn't have.

Against Obsidian, the closest local-first comparison, the real difference is collaboration. AFFiNE supports real-time multi-user editing natively; Obsidian's collaboration story relies on third-party sync plugins layered on top of what's fundamentally a single-user local app.

Against Miro, a whiteboard-only tool, AFFiNE's whiteboard is one mode inside a broader workspace that also includes docs and databases, so teams that need both don't end up paying for and context-switching between two separate subscriptions.

## Getting Started

Deploy the template, but set `AFFINE_ADMIN_EMAIL` and a real `AFFINE_ADMIN_PASSWORD` first: at least 1 uppercase letter, 2 digits, and 2 special characters, confirmed as a hard requirement from AFFiNE's own docs, not a suggestion. Once deployed, open your domain (it redirects to `/admin/setup`) and log in, the account already exists by the time you land on the page. Create your first workspace and start writing.

## Why Deploy AFFiNE Self-Hosted on Railway?

Because the two obvious alternatives, a per-seat Notion subscription or manually wiring Postgres and Redis yourself, both cost you something. Notion's per-seat pricing scales against your team's growth regardless of actual usage. Manually deploying AFFiNE means correctly sequencing its database migration before the app starts, which AFFiNE's own official setup solves with a second container that Railway's `preDeployCommand` handles more cleanly on a single service. This template does that wiring for you, verified against a real live deploy that worked cleanly on the first attempt. Railway offers a $5 free trial so you can test your AFFiNE deployment before committing to production use.

## Frequently Asked Questions

### Why does AFFINE_ADMIN_PASSWORD need such a specific format?
AFFiNE requires at least 1 uppercase letter, 2 digits, and 2 special characters, confirmed directly from AFFiNE's own self-host documentation. This template's default value generates a password guaranteeing each required character class rather than leaving it to chance.

### Why does this template deploy 3 services instead of just the app?
Because that's AFFiNE's real official architecture: a pgvector-enabled Postgres for persistent data and Redis for caching and background jobs, verified directly against AFFiNE's own official Docker Compose setup.

### What happens to my workspaces if I redeploy?
Nothing, as long as the volumes stay attached. Docs, whiteboards, and databases live in Postgres; local file attachments live in the app's own mounted volume, both persist independently.

### Is my workspace data private?
Yes. Every service runs on infrastructure you control, over Railway's private network, with no third party touching your docs, whiteboards, or files.

### How is this different from just using Notion?
Cost and feature shape, mainly. Notion is simpler to start with and requires zero setup, but bills $10-20 per seat per month and has no native whiteboard. This template gets you a comparable doc and database workspace, plus a real whiteboard, for a flat infrastructure cost.

### Does the whiteboard actually work, or is it a lightweight bolt-on?
It's a genuine first-class workspace mode, verified live in this deployment, an actual infinite canvas, not a drawing tool layered onto the doc editor.

### Can I use AFFiNE's AI features self-hosted?
AFFiNE's copilot/AI features require additional provider configuration beyond what this template sets up by default; the core doc, whiteboard, and database features work fully out of the box without any AI provider key.

## Similar templates

- [Libredesk - Complete Setup](https://railway.com/deploy/libredesk-complete-setup) — Complete self-hosted omnichannel customer support desk.
- [Paperless-ngx](https://railway.com/deploy/paperless-ngx-3) — Paperless-ngx — document management with OCR and full-text search
- [Instatic CMS - Postgres](https://railway.com/deploy/instatic-cms-postgres) — Design, build and manage powerful static sites from state-of-the-art CMS

Open this page in a browser: https://railway.com/deploy/affine-open-source
