---
title: "Deploy FerretDB"
description: "FerretDB 2.7 MongoDB-compatible database on Postgres with DocumentDB."
category: "Storage"
url: https://railway.com/deploy/ferretdb-1
---

# Deploy FerretDB

FerretDB 2.7 MongoDB-compatible database on Postgres with DocumentDB.

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

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

- **Creator:** Agaz Self-Host
- **Category:** Storage

## Template content

### ferretdb https://github.com/FerretDB.png

- **Image:** ferretdb/ferretdb:2.7.0
- **Health check:** /debug/readyz

### documentdb https://devicons.railway.app/i/postgresql.svg

- **Image:** ferretdb/postgres-documentdb:17-0.107.0-ferretdb-2.7.0

## Documentation

# Deploy and Host FerretDB on Railway

FerretDB is an open-source, MongoDB-compatible database that stores documents in PostgreSQL through Microsoft's DocumentDB extension. Existing MongoDB drivers, tools and ODMs such as Mongoose connect unchanged, while the data lives in Postgres under an Apache 2.0 license, making it a truly open replacement for MongoDB.

## About Hosting FerretDB

This template deploys FerretDB v2.7.0 with its matching PostgreSQL 17 image that includes the DocumentDB extension, stored on a Railway volume. MongoDB clients authenticate with the Postgres username and generated password over SCRAM. Services on Railway connect over the private network on port 27017, and external clients use the Railway TCP proxy. Telemetry is off. Both images come from Docker Hub; the same database image from GHCR stalled during deployment on Railway in testing. Storage grows with data; watch the volume on the Hobby plan. Back up the database volume regularly.

## Common Use Cases

- Running MongoDB applications on an open-source, Postgres-backed database
- Moving off MongoDB SSPL licensing while keeping drivers and queries
- Document storage with Postgres backups and tooling

## Dependencies for FerretDB Hosting

- `ferretdb/ferretdb:2.7.0` (official image)
- `ferretdb/postgres-documentdb:17-0.107.0-ferretdb-2.7.0` with a volume
- A Railway TCP proxy for external MongoDB clients

### Deployment Dependencies

- [FerretDB documentation](https://docs.ferretdb.io/)
- [FerretDB v2.7.0 release](https://github.com/FerretDB/FerretDB/releases/tag/v2.7.0)
- [MongoDB compatibility](https://docs.ferretdb.io/migration/compatibility/)
- [Railway TCP proxy](https://docs.railway.com/reference/tcp-proxy)

### Implementation Details

| Service | Image | Networking | Storage |
| --- | --- | --- | --- |
| ferretdb | `ferretdb/ferretdb:2.7.0` | private 27017; TCP proxy to 27017 | none |
| documentdb | `ferretdb/postgres-documentdb:17-0.107.0-ferretdb-2.7.0` | private only | volume at `/var/lib/postgresql/data` |

```env
MONGODB_URL=${{ferretdb.MONGODB_URL}}               # inside Railway
MONGODB_PUBLIC_URL=${{ferretdb.MONGODB_PUBLIC_URL}} # external, via TCP proxy
```

```bash
mongosh "$MONGODB_PUBLIC_URL" --eval 'db.orders.insertOne({sku: "a1", qty: 2})'
```

| Variable | Service | Default | Purpose |
| --- | --- | --- | --- |
| `POSTGRES_USER` / `POSTGRES_PASSWORD` | documentdb | `ferret` / generated | Database and MongoDB credentials |
| `FERRETDB_POSTGRESQL_URL` | ferretdb | references | Backend connection |

Notes:

- The TCP proxy carries MongoDB traffic without TLS; use the private network for production apps where possible.
- Some MongoDB features are not supported yet; check the compatibility page before migrating.

This is a community-maintained deployment package and does not imply affiliation with or endorsement by the FerretDB project or its maintainers.

## Why Deploy FerretDB on Railway?

Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.

By deploying FerretDB on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.


## 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/ferretdb-1
