---
title: "Deploy SurfSense"
description: "Open-source AI research agent (NotebookLM alternative)"
category: "AI/ML"
url: https://railway.com/deploy/surfsense
---

# Deploy SurfSense

Open-source AI research agent (NotebookLM alternative)

**[Deploy SurfSense on Railway](https://railway.com/template/surfsense)**

- **Creator:** darseen
- **Category:** AI/ML
- **Total deploys:** 2

## Template content

### frontend https://cdn.jsdelivr.net/gh/MODSetter/SurfSense@main/surfsense_web/public/icon-128.svg

- **Image:** ghcr.io/modsetter/surfsense-web:latest

### zero-cache https://devicons.railway.app/railway

- **Image:** rocicorp/zero:1.6.0

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

- **Image:** pgvector/pgvector:pg17
- **Start command:** `docker-entrypoint.sh postgres -c wal_level=logical -c max_replication_slots=10 -c max_wal_senders=10 -c max_connections=200 -c shared_buffers=256MB`

### backend https://cdn.jsdelivr.net/gh/MODSetter/SurfSense@main/surfsense_web/public/icon-128.svg

- **Image:** ghcr.io/modsetter/surfsense-backend:latest
- **Health check:** /ready

### proxy https://cdn.jsdelivr.net/gh/selfhst/icons@main/svg/caddy.svg

- **Image:** caddy:2-alpine
- **Start command:** `sh -c 'printf "%s" "$CADDYFILE" > /etc/caddy/Caddyfile && exec caddy run --config /etc/caddy/Caddyfile --adapter caddyfile'`
- **Health check:** /proxy-healthz
- **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 SurfSense on Railway

SurfSense is an open-source AI research agent and NotebookLM alternative. It connects your personal knowledge base to search engines, Slack, Notion, Gmail, GitHub, and 15+ other sources, letting you chat with your documents, generate podcasts, and run deep research agents — all on your own infrastructure with your own LLM keys.

## About Hosting SurfSense

SurfSense is a six-service stack: a FastAPI backend (which also runs Alembic migrations, a Celery worker, and Celery beat), a Next.js frontend, Postgres with pgvector and logical replication enabled, Redis as the Celery broker, a Zero sync engine for real-time UI updates, and a Caddy proxy that serves everything from a single public origin — required for session cookies and Zero's websocket paths. This template wires all of it together with private networking, persistent volumes for Postgres, uploaded files, and the Zero replica, and generated secrets. First boot takes ~15–20 minutes while the backend image pulls and migrations run; zero-cache restarting during that window is expected and self-heals.

## Common Use Cases

- Private, self-hosted NotebookLM alternative: upload documents (50+ file formats) and chat with them using your own LLM API keys, with cited answers
- Team research hub that indexes Slack, Notion, Jira, Linear, Gmail, Google Drive, GitHub, and more into one searchable, agent-accessible knowledge base
- Content generation from your knowledge base: podcasts with local TTS, deep research reports, and browser-extension capture of pages you visit

## Dependencies for SurfSense Hosting

- An LLM provider API key (OpenAI, Anthropic, Gemini, or any LiteLLM-compatible provider) — configured in the app after signup
- Nothing else: document parsing (Docling), embeddings (sentence-transformers), TTS (Kokoro), and STT (Faster-Whisper) all run locally by default

### Deployment Dependencies

- [SurfSense GitHub repository](https://github.com/MODSetter/SurfSense)
- [SurfSense documentation](https://docs.surfsense.com)
- [Backend image (ghcr.io)](https://github.com/MODSetter/SurfSense/pkgs/container/surfsense-backend)
- [Frontend image (ghcr.io)](https://github.com/MODSetter/SurfSense/pkgs/container/surfsense-web)
- [Rocicorp Zero (real-time sync)](https://zero.rocicorp.dev)
- [pgvector](https://github.com/pgvector/pgvector)

### Implementation Details

**Single public origin.** Only the Caddy proxy is exposed. It routes `/auth`, `/users`, and `/api/v1` to the backend, `/zero/*` to the Zero sync engine (websockets), and everything else to the frontend — mirroring the upstream production Caddyfile. The full Caddy config lives in the proxy service's `CADDYFILE` variable, so you can edit routing without rebuilding an image.

**Combined backend roles.** The backend container runs with `SERVICE_ROLE=all` (migrations + API + Celery worker + beat), because the API and worker exchange uploaded files through a shared temp directory:

```
SERVICE_ROLE=all   # migrate → api + worker + beat in one container
```

**Postgres with logical replication.** The database starts with `wal_level=logical` and replication slots enabled — required by Zero. The `zero_publication` is created automatically by the backend's migrations on first boot; zero-cache waits (crash-looping by design, restart policy ALWAYS) until it exists.

**Secrets.** Postgres password, backend `SECRET_KEY`, Zero admin password, and the zero-cache↔frontend API key are generated per deploy; every cross-service value is wired with reference variables (e.g. `${{db.POSTGRES_PASSWORD}}`), so nothing needs manual configuration.

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

- [Chat Chat](https://railway.com/deploy/-WWW5r) — Chat Chat, your own unified chat and search to AI platform.
- [stella](https://railway.com/deploy/stella) — Self-host stella with web, API, Postgres, Redis, and object storage.
- [Hermes Agent | OpenClaw Alternative with Dashboard](https://railway.com/deploy/hermes-agent-or-openclaw-alternative-wit) — Self-Hosted Hermes AI Agent for Telegram, Discord & Slack

Open this page in a browser: https://railway.com/deploy/surfsense
