---
title: "Deploy FerretDB | (Just Updated) MongoDB-Compatible Database on Postgres, Auth On, Persistent"
description: "MongoDB-compatible database on Postgres. Auth on, data on a volume."
category: "Storage"
url: https://railway.com/deploy/ferretdb-or-just-updated-mongodb-compati
---

# Deploy FerretDB | (Just Updated) MongoDB-Compatible Database on Postgres, Auth On, Persistent

MongoDB-compatible database on Postgres. Auth on, data on a volume.

**[Deploy FerretDB | (Just Updated) MongoDB-Compatible Database on Postgres, Auth On, Persistent on Railway](https://railway.com/template/ferretdb-or-just-updated-mongodb-compati)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/ferretdb-or-just-updated-mongodb-compati/manifest.json

- **Creator:** SuperSlowSloth
- **Category:** Storage

## Template content

### ferretdb

- **Image:** ferretdb/ferretdb:2.7.0@sha256:5706414241eb84f0515512c37b46db0f1b1eac9e5ceb7e4c2523211c184b1985

### postgres

- **Image:** ferretdb/postgres-documentdb:17-0.107.0-ferretdb-2.7.0@sha256:2386795ec2aa7ae559304361979f1dc5708d383ee9020ae63dadc2940dfe58f7
- **Start command:** `/bin/sh -c 'export POSTGRES_DB=postgres; echo "[railway] uid=$(id -u) owner=$(stat -c %u:%g /var/lib/postgresql)"; exec docker-entrypoint.sh postgres'`

## Documentation

# Deploy and Host FerretDB on Railway

FerretDB is an open-source, MongoDB-compatible database. It speaks the MongoDB wire protocol, so existing drivers, `mongosh` and ORMs connect unchanged, and it stores the documents in PostgreSQL through the DocumentDB extension. This template deploys FerretDB 2.7.0 with the matching DocumentDB-enabled Postgres 17, authentication on, a generated password and a volume for the data. Nothing needs filling in.

## About Hosting FerretDB

The template runs two services. `postgres` is the official `ferretdb/postgres-documentdb` image, pinned by digest, with the extension created at first boot and its data on a volume mounted at `/var/lib/postgresql`. `ferretdb` is the official `ferretdb/ferretdb` image, pinned by digest, listening on port 27017 and reachable through a TCP proxy. Client logins are checked against the database user, so anonymous commands are rejected. Telemetry is disabled.

## Why Deploy FerretDB on Railway?

- A MongoDB-compatible endpoint with an open-source licence and no mongod process.
- Authentication is on and the password is generated per deploy.
- Documents live in Postgres on a volume, so a redeploy keeps them.
- A public TCP proxy URL and a private-network URL are both provided as variables.

## Common Use Cases

- Running a MongoDB-based app without a mongod server or its licence terms.
- Local and CI databases for code that uses a MongoDB driver.
- Giving AI agents a document store they can reach with a standard connection string.
- Keeping documents and relational tables in the same Postgres instance.

## Dependencies for FerretDB Hosting

### Deployment Dependencies

- Image: [ferretdb/ferretdb](https://hub.docker.com/r/ferretdb/ferretdb) 2.7.0, pinned by digest
- Image: [ferretdb/postgres-documentdb](https://hub.docker.com/r/ferretdb/postgres-documentdb) 17-0.107.0-ferretdb-2.7.0, pinned by digest, volume at `/var/lib/postgresql`
- Docs: https://docs.ferretdb.io

## Machine-readable contract

```
service: ferretdb
protocol: MongoDB wire (TCP, port 27017)
public_url_variable: MONGO_PUBLIC_URL   (mongodb://:@:/)
private_url_variable: MONGO_PRIVATE_URL (mongodb://:@:27017/)
credential_variables: MONGO_USER, MONGO_PASSWORD (generated, on the ferretdb service)
health: successful authenticated `ping` over the connection string (no HTTP endpoint)
volumes: /var/lib/postgresql (postgres service)
```

Check it works:

```
mongosh "$MONGO_PUBLIC_URL" --eval 'db.getSiblingDB("test").items.insertOne({ok: 1})'
```


## 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/ferretdb-or-just-updated-mongodb-compati
