---
title: "Deploy MongoDB 9"
description: "MongoDB 9 with auth, persistence, private + public URLs."
category: "Storage"
url: https://railway.com/deploy/mongodb-9
---

# Deploy MongoDB 9

MongoDB 9 with auth, persistence, private + public URLs.

**[Deploy MongoDB 9 on Railway](https://railway.com/template/mongodb-9)**

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

- **Creator:** wotonews
- **Category:** Storage

## Template content

### mongodb

- **Image:** wotonews/mongodb:v9.0.4-2

## Documentation

# Deploy and Host MongoDB 9 with Railway

This template deploys MongoDB 9 as a single service with authentication enabled, a persistent volume, and ready-to-use connection strings for both private-network and external clients.

## About Hosting MongoDB 9

MongoDB is a document database designed for flexible, scalable data storage. This template runs the official `mongo:9.0` Docker image with:

- **Authentication on by default** — a root user (`mongo`) is created on first boot with a password auto-generated at deploy time.
- **Persistence** — a Railway Volume mounted at `/data/db` keeps data across restarts and redeployments.
- **Private networking** — the database listens on the project's private network (`MONGO_URL`), so apps in the same project connect without crossing the public internet.
- **Public access via TCP proxy** — `MONGO_PUBLIC_URL` routes external clients (Compass, DBeaver, your laptop) through Railway's TCP proxy.
- **Zero volume churn** — MongoDB's diagnostic data collection (FTDC) is disabled; metrics live in the Railway dashboard instead of on your volume.

For applications that need change streams, multi-document transactions, or automated failover, deploy the [MongoDB 9 Replica Set](https://railway.com/template/mongodb-9-replica-set) template instead — a three-node replica set with an HAProxy entry point.

## Why Deploy MongoDB 9 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 scale it.

By deploying MongoDB 9 on Railway, you get a production-grade document database with generated credentials, persistent storage, and native private networking, ready the moment it deploys.

## Common Use Cases

- **Primary database for web apps, APIs, and backends** — document models fit flexible, evolving schemas.
- **Data storage for AI agents and automation tools** — pair with any app in the same project via `MONGO_URL`.
- **Development and staging environments** — one click to a real MongoDB, no Atlas account needed.
- **CMS, e-commerce, and real-time platforms** — anywhere a fast document store fits.

## Dependencies for MongoDB 9 Hosting

None — this template is completely standalone.

### Deployment Dependencies

- MongoDB 9.0 official image (thin wrapper: dual-stack bind + ping healthcheck; no forked runtime).
- A Railway Volume at `/data/db` for persistence.
- A Railway TCP proxy for `MONGO_PUBLIC_URL` (external access is optional — private-network apps don't need it).

## Connect After Deployment

Grab these variables from the service (all auto-composed):

| Variable | Use |
|---|---|
| `MONGO_URL` | Private-network connection string (recommended inside Railway) |
| `MONGO_PUBLIC_URL` | Public connection string through the TCP proxy |
| `MONGOHOST` / `MONGOPORT` | Private hostname / port, for manual strings |
| `MONGOUSER` / `MONGOPASSWORD` | Root credentials (auth database: `admin`) |

## Operations

- **Backups**: snapshot or copy the `/data/db` volume; restore follows standard MongoDB procedures.
- **Upgrades**: move between template versions following MongoDB's release notes — data files are forward-compatible within a major version.
- **Scaling**: scale the service vertically (more CPU/RAM); a single node has no horizontal scaling story by design.


## Similar templates

- [RustFS | (Just Updated) S3 Object Store, Public URL and Keys Set](https://railway.com/deploy/rustfs-or-just-updated-s3-object-store-p) — S3-compatible object store, keys and public URL preset, volume kept
- [TimescaleDB](https://railway.com/deploy/timescaledb-railway-template) — A PostgreSQL-based time-series database for analytics on Railway.
- [Garage S3 Storage](https://railway.com/deploy/garage-s3-storage) — Ultra-light S3 server: fast, open-source, plug-and-play.

Open this page in a browser: https://railway.com/deploy/mongodb-9
