---
title: "Deploy MongoDB Single Replica"
description: "Single MongoDB replica set for use with clients needing a replica set."
category: "Storage"
url: https://railway.com/deploy/dxhww9
---

# Deploy MongoDB Single Replica

Single MongoDB replica set for use with clients needing a replica set.

**[Deploy MongoDB Single Replica on Railway](https://railway.com/template/dxhww9)**

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

- **Creator:** Brody's Projects
- **Category:** Storage
- **Total deploys:** 73

## Template content

### Mongo Single Replica https://devicons.railway.app/mongo

- **Source:** railwayapp-templates/mongo-replica-set

### Init Single Replica

- **Source:** railwayapp-templates/mongo-replica-set

## Documentation

This template deploys a single MongoDB instance for your data layer needs.

### Network Communication

All database communication is done over the [private network](https://docs.railway.app/reference/private-networking).

### Configuration tuning

To tune the configuration of your MongoDB instance, refer to the [MongoDB documentation](https://www.mongodb.com/docs/manual/replication/) or the [documentation page in Docker Hub](https://hub.docker.com/_/mongo).

### Authentication

The MongoDB instance is deployed with standard authentication enabled.

### Connecting to MongoDB

To connect to MongoDB from another service in Railway, you should create a URI in the service's environment variables. As an example:

```
MONGO_HOST=${{mongo.RAILWAY_PRIVATE_DOMAIN}}:27017
MONGO_URI=mongodb://${{mongo.MONGO_INITDB_ROOT_USERNAME}}:${{mongo.MONGO_INITDB_ROOT_PASSWORD}}@${{MONGO_HOST}}
```

With these variables set, you can then reference the `MONGO_URI` environment variable when configuring the client in your service code.

### Template source

The source for this template can be found in the [Railway Templates GitHub](https://github.com/railwayapp-templates/mongo-replica-set/tree/main).

The MongoDB instance is built directly from the [official MongoDB image in Docker Hub](https://hub.docker.com/_/mongo).

### Resources
- [MongoDB documentation](https://www.mongodb.com/docs/manual/)
- Tutorial: [Deploy MongoDB on Railway](https://docs.railway.app/tutorials/deploy-and-monitor-mongo)This template deploys a single MongoDB instance for your data layer needs.

### Network Communication

All database communication is done over the [private network](https://docs.railway.app/reference/private-networking).

### Configuration tuning

To tune the configuration of your MongoDB instance, refer to the [MongoDB documentation](https://www.mongodb.com/docs/manual/replication/) or the [documentation page in Docker Hub](https://hub.docker.com/_/mongo).

### Authentication

The MongoDB instance is deployed with standard authentication enabled.

### Connecting to MongoDB

To connect to MongoDB from another service in Railway, you should create a URI in the service's environment variables. As an example:

```
MONGO_HOST=${{mongo.RAILWAY_PRIVATE_DOMAIN}}:27017
MONGO_URI=mongodb://${{mongo.MONGO_INITDB_ROOT_USERNAME}}:${{mongo.MONGO_INITDB_ROOT_PASSWORD}}@${{MONGO_HOST}}
```

With these variables set, you can then reference the `MONGO_URI` environment variable when configuring the client in your service code.

### Template source

The source for this template can be found in the [Railway Templates GitHub](https://github.com/railwayapp-templates/mongo-replica-set/tree/main).

The MongoDB instance is built directly from the [official MongoDB image in Docker Hub](https://hub.docker.com/_/mongo).

### Resources
- [MongoDB documentation](https://www.mongodb.com/docs/manual/)
- Tutorial: [Deploy MongoDB on Railway](https://docs.railway.app/tutorials/deploy-and-monitor-mongo)

## 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/dxhww9
