---
title: "Deploy FerretDB (MongoDB Alternative)"
description: "Open-source MongoDB alternative. FerretDB 2.x + Postgres DocumentDB."
category: "Storage"
url: https://railway.com/deploy/ferretdb-mongodb-alternative
---

# Deploy FerretDB (MongoDB Alternative)

Open-source MongoDB alternative. FerretDB 2.x + Postgres DocumentDB.

**[Deploy FerretDB (MongoDB Alternative) on Railway](https://railway.com/template/ferretdb-mongodb-alternative)**

- **Creator:** Nick K's Projects
- **Category:** Storage
- **Total deploys:** 1

## Template content

### ferretdb

- **Image:** ghcr.io/ferretdb/ferretdb:2.7.0

### Postgres

- **Image:** ghcr.io/ferretdb/postgres-documentdb:17-0.107.0-ferretdb-2.7.0

## Documentation

# Deploy and Host FerretDB (MongoDB Alternative) on Railway

FerretDB is the truly open-source MongoDB alternative. It speaks the MongoDB wire protocol — so your existing drivers, Mongoose/​Prisma code, `mongosh`, and Compass keep working — while storing data in reliable PostgreSQL with Microsoft's DocumentDB extension. No SSPL license worries, no vendor lock-in, real Postgres durability underneath.

## About Hosting FerretDB (MongoDB Alternative)

This template deploys the full FerretDB 2.x stack in one click: a PostgreSQL 17 instance with the DocumentDB extension (the storage engine FerretDB 2.x requires) on a persistent Railway volume, plus the FerretDB proxy wired to it over Railway's private network. A strong database password is auto-generated at deploy time, and a public TCP endpoint is exposed on the MongoDB port (27017) so you can connect from anywhere. Grab your connection string from the ferretdb service and you're live in about a minute.

**Connect from your app:**

```
mongodb://:@:/
```

Find the TCP proxy domain/port on the ferretdb service → Settings → Public Networking. The user and password are on the Postgres service variables. Apps deployed inside the same Railway project can use the private hostname `ferretdb.railway.internal:27017` instead — free, faster, and never leaves Railway's network.

## Common Use Cases

- Drop-in MongoDB replacement for Node.js/Express, NestJS, Python, or Go apps using standard MongoDB drivers
- Escaping MongoDB Atlas pricing or the SSPL license while keeping your existing codebase unchanged
- New projects that want a document API with battle-tested PostgreSQL storage and backups underneath

## Dependencies for FerretDB (MongoDB Alternative) Hosting

- PostgreSQL 17 with the DocumentDB extension (included as the `Postgres` service in this template)
- Persistent Railway volume for the database files (included, mounted at `/var/lib/postgresql/data`)

### Deployment Dependencies

- [FerretDB documentation](https://docs.ferretdb.io/)
- [FerretDB on GitHub](https://github.com/FerretDB/FerretDB)
- [Supported MongoDB commands &amp; compatibility](https://docs.ferretdb.io/reference/supported-commands/)

### Implementation Details

The `ferretdb` service connects to Postgres via:

```
FERRETDB_POSTGRESQL_URL=postgres://user:pass@postgres-private-domain:5432/postgres
```

Authentication uses your PostgreSQL credentials over SCRAM — the same `POSTGRES_USER` / `POSTGRES_PASSWORD` pair works as your MongoDB username/password. Both images are the official FerretDB 2.7.0 releases published on GitHub Container Registry.

## Why Deploy FerretDB (MongoDB Alternative) 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 (MongoDB Alternative) 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-mongodb-alternative
