---
title: "Deploy AFFiNE"
description: "A basic, out-of-the-box setup of Affine."
category: "Other"
url: https://railway.com/deploy/affine-1
---

# Deploy AFFiNE

A basic, out-of-the-box setup of Affine.

**[Deploy AFFiNE on Railway](https://railway.com/template/affine-1)**

- **Creator:** Lev's Projects
- **Category:** Other
- **Total deploys:** 24

## Template content

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

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

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

- **Image:** ghcr.io/toeverything/affine:stable
- **Start command:** `sh -c 'node ./scripts/self-host-predeploy.js && node dist/main.js'`
- **Health check:** /api/health
- **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"`

## Documentation

# Deploy and Host AFFiNE

One-click template for AFFiNE workspace. Auto-provisions backend, database, caching. Zero config required.

## About Hosting AFFiNE

Template orchestrates AFFiNE NestJS server, PostgreSQL, Redis. Links environment variables and runs pre-deploy DB migrations automatically.

## Common Use Cases

- Instant self-hosted workspace deployment
- Zero-config team wiki/whiteboard setup
- Fast AFFiNE evaluation

## Dependencies for AFFiNE Hosting

None. Template automatically spins up:
- AFFiNE Web/API service
- PostgreSQL database
- Redis instance

### Deployment Dependencies

- [AFFiNE GitHub](https://github.com/toeverything/AFFiNE)
- [AFFiNE Docs](https://docs.affine.pro/)

### Implementation Details 

Custom start command handles DB migrations automatically:
`sh -c "node ./scripts/self-host-predeploy.js && node dist/main.js"`

Healthcheck configured at `/api/health` with 120s timeout to allow initial DB setup.

## Why Deploy AFFiNE 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 AFFiNE 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

- [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/affine-1
