
Deploy DocumentDB
This template deploys the latest official DocumentDB image on Railway.
documentdb
microsoft/documentdb/documentdb-local:latest
Just deployed
/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:
- Copy the value of
${{documentdb.URL}}
. - Paste it into MongoDB Compass or Mongosh connection input.
That’s it—you’ll be connected to your DocumentDB instance.
Template Content