Skip to content

CockroachDB

Managed CockroachDB: a distributed SQL database that speaks the PostgreSQL wire protocol, with single-node or multi-node high availability.

From the StackBlaze dashboard, click New service, then Database, then CockroachDB. Pick a plan and storage size, and StackBlaze provisions the instance for you.

Connecting a CockroachDB instance to a service injects the DATABASE_URL environment variable into that service. Your application reads the connection details from this variable, so there is nothing to hardcode.

CockroachDB speaks the PostgreSQL wire protocol, so any PostgreSQL driver, ORM, or client library works without modification. Point your existing Postgres tooling at the connection string and it just works.

Services in the same project reach the database over the cluster’s private network using its internal hostname. The internal connection string takes the form below (note the CockroachDB default port 26257):

Connection string (internal)
postgresql://user:password@[service-name]:26257/dbname?sslmode=verify-full

You choose between Standard and high availability when creating the instance. Standard runs a single node, which is a great fit for development and lower-stakes workloads. High availability runs a multi-node cluster (three or more nodes) where every node serves both reads and writes. If a node is lost, the cluster keeps serving traffic with no manual failover.

Standard High availability
Topology Single node Multi-node cluster (3 or more nodes)
Reads and writes Served by the one node Served by every node
Survives a node loss No Yes, with no manual failover
Best for Development and testing Production and resilient workloads

Because CockroachDB is wire-compatible with PostgreSQL, the standard node-postgres (pg) client connects directly using the injected DATABASE_URL:

db.js
const { Pool } = require('pg')
const pool = new Pool({
connectionString: process.env.DATABASE_URL,
})
async function main() {
const { rows } = await pool.query('SELECT now()')
console.log(rows[0])
}
main()

StackBlaze takes automated, encrypted backups daily. These follow the platform backup policy that applies to all managed databases. For details on schedules, restores, and how the policy works, see Backups & recovery.