Back to articles
Technology Insight

Configuring FerretDB with PostgreSQL: Run Your MongoDB Applications Without Commercial Licensing Worries

June 1, 2026

The Database Licensing Conundrum: Why Businesses are Looking Beyond MongoDB

For nearly a decade, MongoDB stood as the undisputed pioneer of the NoSQL revolution. Its document-oriented storage, dynamic schemas, and intuitive query language captured the hearts of developers globally. However, the landscape shifted dramatically in 2018 when MongoDB transitioned its open-source license from the GNU AGPLv3 to the Server Side Public License (SSPL). This strategic pivot created a complex compliance minefield for enterprise organizations and cloud service providers.

Under the terms of the SSPL, if an organization offers MongoDB as a publicly available service, they must openly release the source code of their entire management platform and infrastructure stack. For modern enterprises utilizing proprietary orchestration tools, security wrappers, and hybrid-cloud deployment frameworks, this requirement introduces immense legal risks. Consequently, many legal teams have placed strict bans on SSPL-licensed software within production environments. Businesses find themselves caught in a difficult position: they love the MongoDB API and developer ecosystem, but they cannot accept the commercial constraints of its modern licensing model.

Enter FerretDB. Built as a direct response to this dilemma, FerretDB serves as an open-source, drop-in replacement for MongoDB that translates MongoDB wire protocol queries directly into standard SQL. By pairing FerretDB with an enterprise-grade relational database like PostgreSQL, organizations can continue running their existing MongoDB applications natively without altering a single line of application code—and entirely free from SSPL liability.

Understanding the Architecture: How FerretDB Bridges the Gap

To fully appreciate the elegance of this solution, it helps to understand how FerretDB operates under the hood. FerretDB is not a standalone database engine; it does not handle disk storage, transaction logging, or low-level memory allocation. Instead, it functions as a highly optimized protocol proxy layer.

Key Concept: FerretDB acts as a stateless translation proxy. It listens for standard MongoDB wire protocol commands (version 5.0+) from your application, parses those requests, converts them into equivalent PostgreSQL JSONB queries, and executes them against a PostgreSQL backend.

This decoupling offers profound structural and operational advantages for modern infrastructure teams:

  • Stateless Scaling: Because FerretDB contains no persistent state, you can scale the proxy layer horizontally across multiple containers or Kubernetes pods to manage fluctuating connection volumes.
  • Document Storage via JSONB: PostgreSQL possesses one of the most mature, heavily optimized binary JSON implementations in the database industry (JSONB). FerretDB leverages this exact capability to store BSON data formats seamlessly without losing index performance or structural flexibility.
  • True Open-Source Compliance: FerretDB is distributed under the highly permissive Apache License 2.0, while PostgreSQL utilizes the PostgreSQL License (similar to BSD/MIT). This dual stack provides complete legal peace of mind for corporate compliance boards.

Step-by-Step Production Configuration Guide

Deploying FerretDB alongside PostgreSQL is straightforward. In this guide, we will walk through a production-ready configuration utilizing Docker Compose, illustrating how to link the application tier to this open-source architecture.

1. Preparing the Environment via Docker Compose

The cleanest method for deploying this architecture is containerization. Create a file named docker-compose.yml and insert the configuration specified below. This setup establishes an isolated network environment, provisions a PostgreSQL container with persistent volumes, and wires the FerretDB proxy directly to it.

version: '3.8'

services:
  postgres:
    image: postgres:16-alpine
    container_name: postgres_backend
    environment:
      POSTGRES_USER: ferret_admin
      POSTGRES_PASSWORD: SecureVaultPassword2026
      POSTGRES_DB: ferret_metadata
    volumes:
      - pgdata:/var/lib/postgresql/data
    networks:
      - db_network
    ports:
      - "5432:5432"

  ferretdb:
    image: ghcr.io/ferretdb/ferretdb:1.21.0
    container_name: ferretdb_proxy
    environment:
      FERRETDB_POSTGRESQL_URL: "postgres://ferret_admin:SecureVaultPassword2026@postgres:5432/ferret_metadata?sslmode=disable"
      FERRETDB_LISTEN_ADDR: "0.0.0.0:27017"
    networks:
      - db_network
    ports:
      - "27017:27017"
    depends_on:
      - postgres

volumes:
  pgdata:

networks:
  db_network:
    driver: bridge

2. Executing and Verifying the Deployment Stack

Once your configuration file is saved, execute the following terminal command within that directory to initialize your containers in the background:

docker-compose up -d

To ensure that the proxy translation layer has securely authenticated with the PostgreSQL database, inspect the container logs:

docker-compose logs ferretdb

Look for lines indicating that the listener has started successfully on port 27017 and that the PostgreSQL connection pool has been initialized. You now have a fully operational MongoDB-compatible endpoint backed by open-source relational power.

Connecting Existing Applications to Your New Stack

One of the primary benefits of adopting FerretDB is that it requires zero modifications to your codebase. Your software continues to utilize its preferred native MongoDB driver (such as Mongoose for Node.js, PyMongo for Python, or the official Go driver).

To redirect your application workload away from MongoDB and toward your new open-source infrastructure stack, simply adjust your standard MongoDB connection string format to target the FerretDB host:

mongodb://ferret_admin:SecureVaultPassword2026@localhost:27017/my_application_db?authSource=admin

When your application initializes, it communicates over standard MongoDB wire protocols. FerretDB dynamically intercept these calls, maps them to PostgreSQL schemas, handles indexing, and returns responses exactly as a native MongoDB engine would expect.

Performance, Indexing, and Enterprise-Grade Reliability

A common concern among infrastructure architects when considering translation proxies is raw performance overhead. However, because PostgreSQL's JSONB implementation is incredibly mature, the performance trade-offs are surprisingly minimal for a vast majority of typical transactional business workloads.

How FerretDB Maps Database Concepts

MongoDB Concept PostgreSQL Translation Equivalent
Database PostgreSQL Schema
Collection PostgreSQL Table (with a predefined JSONB column named _jsonb)
Document Table Row containing binary JSON data
_id Field Primary Key constraints on the underlying table row

Furthermore, FerretDB seamlessly maps standard MongoDB index generation requests into native PostgreSQL GIN (Generalized Inverted Index) structures. This ensures that complex sub-document queries, nested arrays, and rapid lookups maintain sub-millisecond execution speeds even as your document counts scale into millions of rows.

Strategic Benefits for Enterprise Technology Leaders

Choosing to migrate your application backend infrastructure to the FerretDB and PostgreSQL combination delivers immediate strategic advantages across your entire technical organization:

  1. Drastic Licensing Cost Reduction: Eliminate tracking commercial node licenses or navigating complex compliance Audits regarding proprietary code distribution.
  2. Unified Data Infrastructure: Instead of splitting your database administrators (DBAs) into separate operational silos for SQL and NoSQL, your infrastructure teams can focus entirely on optimizing, securing, and backing up a single, unified database platform: PostgreSQL.
  3. Mitigation of Vendor Lock-In: By utilizing standardized database engines, you maintain complete portability. You can deploy this exact stack on-premises, across bare metal servers, or within managed Kubernetes clusters on any public cloud provider without facing cloud provider licensing premiums.

Conclusion: Embracing Open-Source Autonomy

As corporate legal departments become increasingly stringent regarding the software packages embedded in enterprise infrastructure, software architects must build for long-term sustainability. The innovative pairing of FerretDB and PostgreSQL provides the ultimate compromise: it preserves the agility, familiarity, and rich developer experience of the MongoDB API while anchoring your application data on the rock-solid, fully open-source foundation of PostgreSQL.

By migrating your non-relational storage needs to this powerful architecture today, you protect your business from future licensing pivots and ensure your infrastructure remains truly open, scalable, and resilient for years to come.

Configuring FerretDB with PostgreSQL: Run Your MongoDB Applications Without Commercial Licensing Worries | DPTCloud