---
title: "Deploy DocumentDB"
description: "This template deploys the latest official DocumentDB image on Railway."
category: "Storage"
url: https://railway.com/deploy/documentdb-1
---

# Deploy DocumentDB

This template deploys the latest official DocumentDB image on Railway.

**[Deploy DocumentDB on Railway](https://railway.com/template/documentdb-1)**

- **Creator:** mahmoud ™'s Projects
- **Category:** Storage

## Template content

### documentdb https://documentdb.io/images/DocumentDB%20Logo%20-%20background%20removed.png

- **Image:** ghcr.io/microsoft/documentdb/documentdb-local:latest

## Documentation

# Deploy and Host DocumentDB on Railway

**DocumentDB** is a powerful, scalable, MongoDB-compatible open-source document database built on PostgreSQL.

You can connect just like you would with MongoDB:

```python
from pymongo import MongoClient, AsyncMongoClient

mongo_client: MongoClient = MongoClient(MONGO_URL)
```

Set the environment variable:

```bash
MONGO_URL=${{documentdb.PRIVATE_URL}}
```

If you prefer, you can also use:

```bash
MONGO_URL=${{documentdb.URL}}
```

⚠️ Note: Using the public `URL` incurs **egress costs**. The `PRIVATE_URL` avoids this when used inside Railway’s network.

---

## About Hosting DocumentDB

Deploying DocumentDB on Railway involves:

* Creating a **service** (DocumentDB instance)
* Attaching a **volume** for persistent storage

This setup ensures your data remains safe and accessible across deployments.

---

## Connect via MongoDB Compass or Mongosh

You can connect directly using the `URL` environment variable:

1. Copy the value of `${{documentdb.URL}}`.
2. Paste it into **MongoDB Compass** or **Mongosh** connection input.

That’s it—you’ll be connected to your DocumentDB instance.


## Similar templates

- [Garage S3 Storage](https://railway.com/deploy/garage-s3-storage) — Ultra-light S3 server: fast, open-source, plug-and-play.
- [Redis](https://railway.com/deploy/redis-1) — Self Host Latest Redis with Railway
- [EasyImg](https://railway.com/deploy/easyimg) — Simple self-hostable Nuxt.js personal image hosting system.

Open this page in a browser: https://railway.com/deploy/documentdb-1
