Deploy DocumentDB

This template deploys the latest official DocumentDB image on Railway.

Deploy DocumentDB

/home/documentdb/postgresql

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:

from pymongo import MongoClient, AsyncMongoClient

mongo_client: MongoClient = MongoClient(MONGO_URL)

Set the environment variable:

MONGO_URL=${{documentdb.PRIVATE_URL}}

If you prefer, you can also use:

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.


Template Content

More templates in this category

View Template
Postgres Backup to Cloudflare R2
Auto back up PostgreSQL databases to Cloudflare R2 with optional encryption

View Template
ReadySet
A lightweight caching engine for Postgres

View Template
Simple S3
Deploy a S3-compatible storage service with a pre-named bucket.