Railway

Deploy paperless-ngx

Document management with OCR on Railway with PostgreSQL and Redis

Deploy paperless-ngx

Just deployed

/data

/var/lib/postgresql/data

Just deployed

Deploy to Railway

Deploy and Host Paperless-ngx on Railway

Paperless-ngx is the fork of the original Paperless application — a document management system that transforms your physical documents into a searchable digital archive. It features OCR, automatic tagging, document classification, and a modern web interface.

About Hosting Paperless-ngx on Railway

This template deploys Paperless-ngx with PostgreSQL (database), Valkey/Redis (task broker), and persistent storage volumes on Railway. The Paperless service runs the web server and background task consumer in a single process.

Features

  • OCR & Text Extraction — Automatic text recognition from scanned documents
  • Document Tagging — Automatic and manual tagging with AI-powered suggestions
  • Search — Full-text search across all documents
  • Document Types — Support for PDF, Office docs, images, emails, and more
  • Consumption Directory — Drop files to automatically ingest and process
  • API — RESTful API for programmatic access
  • Multi-user — Role-based access control with Django auth
  • Dark Mode — Built-in dark theme support

Why Deploy Paperless-ngx on Railway

  • One-click deployment — PostgreSQL and Redis are set up automatically as companion services
  • Persistent storage — Database and document data persist across deploys via Railway volumes
  • Auto-scaling — Scale vertically as your document archive grows
  • Custom domains — Add your own domain with automatic TLS certificates
  • Managed infrastructure — No need to manage your own database or Redis instances

Quick Start

  1. Click the Deploy to Railway button above
  2. Wait for provisioning (~2-3 minutes for image pull and DB init)
  3. Open the application at your deployed Railway URL
  4. The default admin credentials are printed in the deployment logs

Prerequisites

  • A Railway account (free tier available)
  • No local setup required — everything runs on Railway

Architecture

                    ┌─────────────────────────────────────────────────────┐
                    │           Railway Project                           │
                    │                                                     │
  ┌─────────────┐   │  ┌──────────────────────┐                         │
  │  PostgreSQL │   │  │   Paperless-ngx      │                         │
  │  (companion)│   │  │   (main service)     │                         │
  │  port 5432  │   │  │   port 8000          │                         │
  └─────────────┘   │  └──────────┬───────────┘                         │
                    │             │                                      │
  ┌─────────────┐   │             │                                      │
  │  Valkey     │   │             │                                      │
  │  (Redis)    │   │             │                                      │
  │  (companion)│   │             │                                      │
  │  port 6379  │   │             │                                      │
  └─────────────┘   │             │                                      │
                    │             │                                      │
                    │  ┌──────────▼───────────┐                          │
                    │  │  Persistent Volumes  │                          │
                    │  │  (postgres + redis   │                          │
                    │  │   + paperless data)  │                          │
                    │  └──────────────────────┘                          │
                    └─────────────────────────────────────────────────────┘

Common Use Cases

  • Personal document archiving and search
  • Small office paperless workflow
  • Receipt and invoice management
  • Academic paper organization
  • Legal document management

Dependencies for Paperless-ngx on Railway

This template requires the following services:

Deployment Dependencies

  • PostgreSQL — Required. Automatically deployed as a companion service.
  • Valkey/Redis — Required. Automatically deployed as a companion service for Celery task broker.

Configuration

Environment Variables

VariableDefaultDescription
PORT8000Port for the Paperless-ngx web server
PAPERLESS_SECRET_KEY(auto)Secret key for session tokens and signing. Auto-generated if not set.
PAPERLESS_REDIS(auto)Redis connection string. Auto-detected from the Redis companion service.
PAPERLESS_DBENGINEpostgresqlDatabase engine (postgresql)
PAPERLESS_DBHOST(auto)PostgreSQL host. Auto-detected from the Postgres companion service.
PAPERLESS_DBPORT5432PostgreSQL port
PAPERLESS_DBNAMEpaperlessDatabase name. Must match POSTGRES_DB on the Postgres service.
PAPERLESS_DBUSER(auto)PostgreSQL username. Auto-detected from the Postgres companion service.
PAPERLESS_DBPASS(auto)PostgreSQL password. Auto-detected from the Postgres companion service.
PAPERLESS_DB_OPTIONS{"sslmode": "prefer"}
PAPERLESS_URL(auto)
PAPERLESS_TIME_ZONEUTCTimezone for document processing
PAPERLESS_OCR_LANGUAGEengDefault OCR language
PAPERLESS_OCR_LANGUAGESengAdditional OCR languages (space-separated)
PAPERLESS_CONSUMER_RECURSIVEtrueWhether consumer recursively scans subdirectories
PAPERLESS_CONSUMER_POLLING_INTERVAL0Polling interval (0 = event-driven)

Postgres Service

VariableDefaultDescription
POSTGRES_USERpaperlessDatabase superuser
POSTGRES_PASSWORDauto-generatedDatabase password (auto-generated secret)
POSTGRES_DBpaperlessInitial database name
PGDATA/var/lib/postgresql/data/pgdataPostgres data directory

Redis Service

VariableDefaultDescription
REDIS_PASSWORDauto-generatedRedis password (auto-generated secret)
REDIS_URLredis://:${REDIS_PASSWORD}@${RAILWAY_PRIVATE_DOMAIN}:6379Redis/Valkey connection URL with password

Persistent Storage

Each service has a Railway volume attached for data persistence:

  • PostgreSQLpostgres-volume mounted at /var/lib/postgresql/data
  • Redisredis-volume mounted at /data
  • Paperless-ngxpaperless-ngx-volume mounted at /usr/src/paperless/data (consumption directory, OCR cache, and other state)

Note: Railway limits each service to one volume. The Paperless-ngx media directory (/usr/src/paperless/media) is not persisted on a separate volume — generated thumbnails and media files can be regenerated by the application.

The Paperless-ngx service exposes a health endpoint at /health. Railway monitors this endpoint to ensure the service is running. The endpoint returns a 302 redirect to the login page when unauthenticated, which Railway accepts as a healthy response.

Project Structure

├── Dockerfile              # Paperless-ngx service build (uses official image)
├── docker-entrypoint.sh    # Railway-aware entrypoint (auto-configures DB/Redis/URL)
├── railway.json            # Railway build/deploy config
├── postgres/
│   ├── Dockerfile          # Postgres service build
│   ├── railway.json        # Postgres deploy config with volume mount
│   └── template-vars.json  # Postgres template variables
├── redis/
│   ├── Dockerfile          # Valkey/Redis service build
│   ├── railway.json        # Redis deploy config with volume mount
│   └── template-vars.json  # Redis template variables
├── template-vars.json      # Template variables for Railway marketplace
└── template-editor-raw.json # Raw template editor variable values

Security Notes

  • Change the default Postgres password (paperless) after first deployment
  • Set a strong PAPERLESS_SECRET_KEY for session token signing (auto-generated on first deploy if left as default)
  • Configure a custom domain with HTTPS for production use
  • The default admin credentials are printed in the Railway deployment logs after first startup

Learn More


Template Content

More templates in this category

View Template
open-excalidraw
Self-hostable collaborative drawing built on Excalidraw

Prateek Mohanty
1
View Template
caring-vibrancy
Deploy and Host caring-vibrancy with Railway

5
View Template
NEW
Appsmith
Low-code platform for internal tools, dashboards, and admin panels.

Agaz Self-Host
0