---
title: "Deploy Overleaf"
description: "Collaborative LaTeX in the cloud — one-click"
category: "Other"
url: https://railway.com/deploy/overleaf
---

# Deploy Overleaf

Collaborative LaTeX in the cloud — one-click

**[Deploy Overleaf on Railway](https://railway.com/template/overleaf)**

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

- **Creator:** railbi
- **Category:** Other
- **Total deploys:** 11

## Template content

### Overleaf https://github.com/overleaf.png

- **Image:** sharelatex/sharelatex:6.1.2
- **Start command:** `env -u PORT /sbin/my_init`
- **Health check:** /status
- **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"`

### Mongo Init

- **Image:** mongo:8.0
- **Start command:** `sh -c 'for i in $(seq 1 90); do mongosh -u "$MONGOUSER" -p "$MONGOPASSWORD" --host "$MONGOHOST" --authenticationDatabase admin --quiet --eval "db.adminCommand({ping:1})" && break; sleep 2; done; mongosh -u "$MONGOUSER" -p "$MONGOPASSWORD" --host "$MONGOHOST" --authenticationDatabase admin --eval "try { rs.status().ok } catch (e) { rs.initiate({_id: \"rs0\", members:[{_id:0, host: process.env.MONGOHOST + \":27017\"}]}) }"; echo INIT_DONE'`

### MongoDB https://devicons.railway.app/i/mongodb.svg

- **Image:** mongo:8.0
- **Start command:** `sh -c 'mkdir -p /data/configdb /data/db; if [ ! -s /data/configdb/keyfile ]; then openssl rand -base64 756 > /data/configdb/keyfile; chown mongodb:mongodb /data/configdb/keyfile; chmod 400 /data/configdb/keyfile; fi; exec docker-entrypoint.sh mongod --replSet rs0 --keyFile /data/configdb/keyfile --ipv6 --bind_ip ::,0.0.0.0 --setParameter diagnosticDataCollectionEnabled=false'`

## Documentation

# Deploy and Host Overleaf on Railway

Overleaf Community Edition is a self-hosted online LaTeX editor for writing, compiling, and collaborating on scientific documents in the browser. It gives you the Overleaf editing experience on your own infrastructure, with projects, real-time preview, and history stored under your control.

## About Hosting Overleaf

Hosting Overleaf means running the web app alongside MongoDB and Redis. Project files live on disk, document metadata lives in MongoDB, and sessions plus real-time collaboration state live in Redis. MongoDB must run as a replica set so Overleaf's change history works. This template wires the three services over Railway's private network, generates database passwords, attaches volumes so data survives redeploys, and publishes only the Overleaf UI. After deploy, create the first admin account at `/launchpad`, then sign in and start a project. Set `OVERLEAF_SITE_LANGUAGE` if you want a UI language other than English.

## Common Use Cases

- Run a private alternative to overleaf.com for yourself or a lab
- Collaborate on papers, theses, and grant proposals in the browser
- Teach LaTeX with an institutional editor that keeps documents in-house
- Compile CVs, posters, and conference abstracts without a local TeX install

## Dependencies for Overleaf Hosting

- Overleaf Community Edition (`sharelatex/sharelatex:6.1.2`)
- MongoDB 8.0 running as a replica set
- Redis 8.2 with password authentication
- Persistent volumes for Overleaf data, MongoDB, and Redis

### Deployment Dependencies

- [Overleaf Community Edition](https://github.com/overleaf/overleaf)
- [Overleaf environment variables](https://docs.overleaf.com/on-premises/configuration/overleaf-toolkit/environment-variables)
- [sharelatex/sharelatex Docker image](https://hub.docker.com/r/sharelatex/sharelatex)
- [Railway volumes](https://docs.railway.com/volumes)
- [Railway private networking](https://docs.railway.com/networking/private-networking)

### Implementation Details

- Create the first admin user at `/launchpad` on your public Overleaf domain after the deployment is healthy.
- `OVERLEAF_SITE_URL` is set automatically from `RAILWAY_PUBLIC_DOMAIN` so links and websockets work on Railway's HTTPS domain.
- Email confirmation is disabled (`EMAIL_CONFIRMATION_DISABLED=true`) so local accounts work without SMTP. Add SMTP variables later if you want invite emails.
- `OVERLEAF_SITE_LANGUAGE` defaults to `en`. Set it to `zh-CN` (or another supported locale) to change the UI language.
- Community Edition is intended for trusted users. Sandboxed compiles are a Server Pro feature and are not enabled here.
- The Community Edition image includes a minimal TeX Live installation. To add packages, build a custom image using tlmgr and deploy that image. Packages installed only in a running container are lost when the container is recreated.
- Redis and MongoDB stay on the private network. Only the Overleaf service is publicly reachable on port 80.
- Keep `PORT=80` and healthcheck path `/status`. Railway healthchecks use `$PORT`, and nginx listens on 80. Do not change the healthcheck to `/health_check` (nginx returns 404).
- The Overleaf start command is `env -u PORT /sbin/my_init`. The CE image's history-v1 process binds `process.env.PORT` and would otherwise fight nginx for port 80, which breaks project creation.

## Why Deploy Overleaf 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 Overleaf 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/overleaf
