---
title: "Deploy Habitica"
description: "Deploy and Host Habitica with a persistent MongoDB backend."
category: "Other"
url: https://railway.com/deploy/her-547-habitica-source
---

# Deploy Habitica

Deploy and Host Habitica with a persistent MongoDB backend.

**[Deploy Habitica on Railway](https://railway.com/template/her-547-habitica-source)**

- **Creator:** Agaz Self-Host
- **Category:** Other

## Template content

### Mongo

- **Image:** mongo:8.0.11@sha256:5941949d3887e40be5175787aade07dc052f2cddb8ce21b740c3948eba6a3ed0
- **Start command:** `sh -ec 'mongod --replSet rs --bind_ip_all --port 27017 & pid=$!; trap "kill $pid" TERM INT; until mongosh --port 27017 --quiet --eval '\''db.adminCommand({ ping: 1 }).ok'\'' >/dev/null 2>&1; do sleep 1; done; mongosh --port 27017 --quiet --eval "try { rs.status() } catch (err) { rs.initiate({ _id: '\''rs'\'', members: [{ _id: 0, host: '\''${RAILWAY_PRIVATE_DOMAIN}:27017'\'' }] }) }"; wait "$pid"'`

### Habitica

- **Image:** awinterstein/habitica-server:5.48.8@sha256:1352a3e100b9f6c297086d58d23d5b520198aa186f5293e1d356ea531ec70bfd
- **Start command:** `sh -c "perl -0pi -e 's/upgradeInsecureRequests: IS_PROD \\? \\[\\] : null,?/upgradeInsecureRequests: null/g' /var/lib/habitica/website/server/middlewares/index.js /var/lib/habitica/website/transpiled-babel/middlewares/index.js && printenv | grep -v 'no_proxy' >> /etc/environment && /etc/init.d/cron start && node /var/lib/habitica/website/transpiled-babel/index.js"`
- **Public domain:** Yes

## Documentation

# Deploy and Host Habitica on Railway

Habitica is an open-source habit-building and task-management application that turns daily goals into a role-playing game. This template provides a private Habitica service with a MongoDB replica set, durable database storage, managed HTTPS, and Railway private networking. It is designed for self-hosted productivity data and uses no customer, social, or production data during validation.

## What is Habitica?

Habitica helps people build habits and complete tasks through game mechanics such as experience, gold, rewards, quests, parties, and challenges. It supports habits, dailies, to-dos, user accounts, groups, and an API for compatible clients. Review Habitica's upstream terms, API guidance, and license before operating a public instance or integrating third-party services.

## About Hosting Habitica

This template runs the pinned Habitica 5.48.8 server image as the only public service. The application listens on port `8080` inside Railway and is reachable through a generated HTTPS domain. A private MongoDB 8.0.11 service runs as a single-node `rs` replica set because Habitica uses MongoDB transactions; its `/data/db` path is mounted on one persistent Railway volume. Railway reference variables wire the app to MongoDB and its generated public domain, so clean deployments have no required manual variables. Email, payment, and external integration credentials are not preconfigured.

Back up the MongoDB volume before upgrades. Test major-version changes in a fresh project and preserve the matching image digest and data backup when rolling back.

## Common Use Cases

- Organize personal habits, daily routines, and long-term goals.
- Run a private task and accountability space for a household or small group.
- Use Habitica's API and compatible clients against a self-hosted instance.

## Dependencies for Habitica Hosting

- Habitica server `5.48.8`, pinned to `awinterstein/habitica-server:5.48.8@sha256:1352a3e100b9f6c297086d58d23d5b520198aa186f5293e1d356ea531ec70bfd`.
- MongoDB `8.0.11`, pinned to `mongo:8.0.11@sha256:5941949d3887e40be5175787aade07dc052f2cddb8ce21b740c3948eba6a3ed0`.
- One Railway volume mounted at `/data/db` for MongoDB data and replica-set state.

### Deployment Dependencies

- [Habitica v5.48.8 release](https://github.com/HabitRPG/habitica/releases/tag/v5.48.8)
- [Habitica upstream README](https://github.com/HabitRPG/habitica/blob/v5.48.8/README.md)
- [Habitica license](https://github.com/HabitRPG/habitica/blob/v5.48.8/LICENSE)
- [Railway volumes](https://docs.railway.com/volumes)
- [Railway health checks](https://docs.railway.com/deployments/healthchecks)

### Implementation Details

The Umbrel package's outer port is `3944`, while the pinned server image reports its internal listener on Railway port `8080`; only the Habitica service receives a public domain. MongoDB remains private and starts with `--replSet rs --bind_ip_all --port 27017`. Its startup wrapper initializes the single-node replica set using the Railway private hostname and then keeps `mongod` in the foreground.

The application uses these Railway references:

- `BASE_URL=https://${{RAILWAY_PUBLIC_DOMAIN}}`
- `NODE_DB_URI=mongodb://${{Mongo.RAILWAY_PRIVATE_DOMAIN}}:27017/habitica?replicaSet=rs`

No application variable lacks a serialized template default. No email provider, payment credential, custom domain, public MongoDB listener, or `app_proxy` service is included.

Habitica code is GPL v3 licensed. Habitica assets and content may have additional upstream terms, including CC-BY-SA 3.0 and CC-BY-NC-SA 3.0 notices in the upstream license. Operators must host and share only content they are authorized to use. Habitica is a productivity application; this template does not enable cryptocurrency mining, proxies, torrenting, scraping, unauthorized access, or other prohibited activity.

## Why Deploy Habitica 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 Habitica 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) — [Jul'26] 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/her-547-habitica-source
