Connect to FerretDB (MongoDB-compatible)
Tested with: FerretDB 2.4.0 with DocumentDB on PostgreSQL 17 · drivers listed per tab · zb CLI 0.1
FerretDB speaks the MongoDB wire protocol and stores documents in a PostgreSQL cluster with the DocumentDB extension, rendered alongside your instance. You use standard MongoDB drivers; backups are PostgreSQL backups with point-in-time recovery.
- Copy the host and port from Connect.
- Download the CA bundle (
zb api GET /v1/orgs/{org}/ca.pem > databasezy-ca.pem) if your driver does not read the OS trust store. - Add your egress IPs under Network → Allow-list.
- Connect with
tls=true,authSource=adminandauthMechanism=SCRAM-SHA-256, as in every snippet below.
FerretDB (MongoDB-compatible) listens on port 27017 (MongoDB wire protocol). Versions: 2.7, 2.4. Replace the example host with the one on your instance's Connect tab; credentials are shown once at creation.
mongodb://app:<password>@ferret-7f3k.us-east.databasezy.com:27017/app?tls=true&tlsCAFile=databasezy-ca.pem&authSource=admin&authMechanism=SCRAM-SHA-256import { MongoClient } from "mongodb";
const uri = `mongodb://app:${process.env.ZB_PASSWORD}@ferret-7f3k.us-east.databasezy.com:27017/app` + "?tls=true&authSource=admin&authMechanism=SCRAM-SHA-256";export const client = new MongoClient(uri, { tlsCAFile: "databasezy-ca.pem", // omit if the OS trust store already has the CA maxPoolSize: 10,});await client.connect();console.log(await client.db("app").command({ ping: 1 }));Tested with: FerretDB (MongoDB-compatible) 2.7 · mongodb 6.10 (Node driver)
import osfrom pymongo import MongoClient
uri = ( f"mongodb://app:{os.environ['ZB_PASSWORD']}@ferret-7f3k.us-east.databasezy.com:27017/app" "?authSource=admin&authMechanism=SCRAM-SHA-256")client = MongoClient(uri, tls=True, tlsCAFile="databasezy-ca.pem", maxPoolSize=10)print(client.app.command("ping"))Tested with: FerretDB (MongoDB-compatible) 2.7 · pymongo 4.10
package main
import ( "context" "fmt" "os"
"go.mongodb.org/mongo-driver/v2/bson" "go.mongodb.org/mongo-driver/v2/mongo" "go.mongodb.org/mongo-driver/v2/mongo/options")
func main() { uri := fmt.Sprintf("mongodb://app:%s@ferret-7f3k.us-east.databasezy.com:27017/app"+ "?tls=true&tlsCAFile=databasezy-ca.pem&authSource=admin&authMechanism=SCRAM-SHA-256&maxPoolSize=10", os.Getenv("ZB_PASSWORD")) client, err := mongo.Connect(options.Client().ApplyURI(uri)) if err != nil { panic(err) } defer client.Disconnect(context.Background())
var res bson.M if err := client.Database("app").RunCommand(context.Background(), bson.D{{Key: "ping", Value: 1}}).Decode(&res); err != nil { panic(err) } fmt.Println(res)}Tested with: FerretDB (MongoDB-compatible) 2.7 · mongo-go-driver v2.0
use mongodb::{bson::doc, options::ClientOptions, Client};
#[tokio::main]async fn main() -> mongodb::error::Result<()> { let pw = std::env::var("ZB_PASSWORD").expect("ZB_PASSWORD"); let uri = format!( "mongodb://app:{pw}@ferret-7f3k.us-east.databasezy.com:27017/app?tls=true&tlsCAFile=databasezy-ca.pem&authSource=admin&authMechanism=SCRAM-SHA-256&maxPoolSize=10" ); let opts = ClientOptions::parse(uri).await?; let client = Client::with_options(opts)?; let res = client.database("app").run_command(doc! { "ping": 1 }).await?; println!("{res}"); Ok(())}Tested with: FerretDB (MongoDB-compatible) 2.7 · mongodb 3.1 (rustls)
// One-time: keytool -importcert -noprompt -alias databasezy -file databasezy-ca.pem \// -keystore databasezy-truststore.p12 -storetype PKCS12 -storepass changeit// Run with: -Djavax.net.ssl.trustStore=databasezy-truststore.p12 -Djavax.net.ssl.trustStorePassword=changeitimport com.mongodb.client.MongoClients;import org.bson.Document;
public final class Db { public static void main(String[] args) { var uri = "mongodb://app:" + System.getenv("ZB_PASSWORD") + "@ferret-7f3k.us-east.databasezy.com:27017/app?tls=true&authSource=admin&authMechanism=SCRAM-SHA-256&maxPoolSize=10"; try (var client = MongoClients.create(uri)) { System.out.println(client.getDatabase("app").runCommand(new Document("ping", 1))); } }}Tested with: FerretDB (MongoDB-compatible) 2.7 · mongodb-driver-sync 5.2
using MongoDB.Bson;using MongoDB.Driver;
var pw = Environment.GetEnvironmentVariable("ZB_PASSWORD");var settings = MongoClientSettings.FromConnectionString( $"mongodb://app:{pw}@ferret-7f3k.us-east.databasezy.com:27017/app?tls=true&authSource=admin&authMechanism=SCRAM-SHA-256");settings.MaxConnectionPoolSize = 10;// The CA is verified against the OS trust store; add databasezy-ca.pem to it if needed.var client = new MongoClient(settings);Console.WriteLine(client.GetDatabase("app").RunCommand<BsonDocument>(new BsonDocument("ping", 1)));Tested with: FerretDB (MongoDB-compatible) 2.7 · MongoDB.Driver 3.1
<?phprequire "vendor/autoload.php";
$uri = sprintf("mongodb://app:%[email protected]:27017/app?authSource=admin&authMechanism=SCRAM-SHA-256", getenv("ZB_PASSWORD"));$client = new MongoDB\Client($uri, ["tls" => true, "tlsCAFile" => "databasezy-ca.pem", "maxPoolSize" => 10]);var_dump($client->selectDatabase("app")->command(["ping" => 1])->toArray()[0]);Tested with: FerretDB (MongoDB-compatible) 2.7 · mongodb/mongodb 1.20 · ext-mongodb 1.20
require "mongo"
client = Mongo::Client.new( "mongodb://app:#{ENV.fetch('ZB_PASSWORD')}@ferret-7f3k.us-east.databasezy.com:27017/app?authSource=admin&authMechanism=SCRAM-SHA-256", ssl: true, ssl_ca_cert: "databasezy-ca.pem", max_pool_size: 10)puts client.database.command(ping: 1).firstTested with: FerretDB (MongoDB-compatible) 2.7 · mongo 2.21
mongosh "mongodb://app:$ZB_PASSWORD@ferret-7f3k.us-east.databasezy.com:27017/app?tls=true&authSource=admin&authMechanism=SCRAM-SHA-256" --tlsCAFile databasezy-ca.pem
# orzb connect ferretdb-7f3kTested with: FerretDB (MongoDB-compatible) 2.7 · mongosh 2.3
Compatibility notes
Section titled “Compatibility notes”- Supported: CRUD, aggregation pipeline (most stages), indexes including compound and TTL, change streams are not supported yet, transactions are single-document.
- Run
db.runCommand({ buildInfo: 1 })to see the FerretDB and DocumentDB versions. - Applications that depend on
$textsearch, GridFS or multi-document transactions should use the Percona Server for MongoDB engine instead; its engine page shows whether it is orderable yet.
Pooling
Section titled “Pooling”Each MongoDB client keeps its own pool (maxPoolSize); one client per process is the norm. Every FerretDB
connection maps to a PostgreSQL connection, so the size’s max_connections is the real ceiling.