CockroachDB Connection String Generator

Generate connection strings for CockroachDB in any format. PostgreSQL-compatible with support for SSL, cluster identifiers, and all major drivers.

Client-side only — nothing leaves your browser

postgresql://root:@localhost:26257/defaultdb?sslmode=verify-full

What is a CockroachDB Connection String?

A CockroachDB connection string contains all the information needed to connect to a CockroachDB cluster: host address, port, database name, credentials, and SSL settings. Because CockroachDB is PostgreSQL wire-compatible, connection strings use the standard postgresql:// URI scheme and work with any PostgreSQL driver. The default port is 26257.

SSL Mode Options

  • disable — No SSL (local development only)
  • require — Use SSL, don't verify certificate
  • verify-full — Verify certificate and hostname (recommended for CockroachDB Cloud)

Quick Reference

FormatExample Pattern
CockroachDB URIpostgresql://user:pass@host:26257/db?sslmode=verify-full
JDBC (Java)jdbc:postgresql://host:26257/db?user=user&password=pass&sslmode=verify-full
.NET (Npgsql)Host=host;Port=26257;Database=db;Username=user;Password=pass;SSL Mode=VerifyFull
Python (psycopg2)postgresql://user:pass@host:26257/db?sslmode=verify-full
Node.js (pg)postgresql://user:pass@host:26257/db?sslmode=verify-full
Go (pgx)postgresql://user:pass@host:26257/db?sslmode=verify-full
PHP (PDO)pgsql:host=host;port=26257;dbname=db;user=user;password=pass
Ruby (pg gem)postgresql://user:pass@host:26257/db?sslmode=verify-full

Frequently Asked Questions

What is a CockroachDB connection string?
A CockroachDB connection string contains all the information needed to connect to a CockroachDB cluster: host address, port, database name, credentials, and SSL settings. Because CockroachDB is PostgreSQL wire-compatible, connection strings use the postgresql:// URI scheme and work with standard PostgreSQL drivers. The default port is 26257 (not 5432 like PostgreSQL).
What is the difference between connecting to CockroachDB and PostgreSQL?
CockroachDB uses the same postgresql:// connection string format as PostgreSQL, so most PostgreSQL drivers work out of the box. The key differences are: CockroachDB defaults to port 26257 instead of 5432, SSL mode verify-full is recommended (especially for CockroachDB Cloud), you may need a cluster identifier for Serverless/Dedicated clusters, and the default database is 'defaultdb' rather than 'postgres'.
How do I connect to CockroachDB Serverless or Dedicated?
For CockroachDB Serverless and Dedicated clusters, you need to include the cluster identifier in your connection string using the options parameter (e.g., options=--cluster=your-cluster-name). You also need to set sslmode=verify-full and provide the path to the CA certificate downloaded from the CockroachDB Cloud console. The host will be your cluster's hostname provided in the Cloud dashboard.
What SSL mode should I use for CockroachDB?
For CockroachDB Cloud (Serverless and Dedicated), use 'verify-full' which is the recommended and most secure option -- it encrypts the connection and verifies both the server certificate and hostname. For local development with a single-node CockroachDB instance, you can use 'disable'. The 'require' mode encrypts the connection but does not verify the server certificate, which is suitable for self-hosted clusters with self-signed certificates.
How do I set the CockroachDB connection pool size and timeout?
CockroachDB connection pool settings are configured in your application driver, not in the connection string itself. For most drivers, set pool size via driver options (e.g., max_pool_size in Python, max in Node.js pg pool). CockroachDB recommends keeping the total number of connections across all application instances below the cluster's connection limit. For timeouts, you can append connect_timeout to the connection string or configure statement_timeout via the options parameter.
CockroachDB

Need a CockroachDB GUI Client?

1bench is a modern database client for CockroachDB and 20+ other databases. Query, browse, and manage your data visually.

Learn More