> ## Documentation Index
> Fetch the complete documentation index at: https://ngquct-docs-fix-500-query-results.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# CockroachDB

> Connect to CockroachDB clusters over the PostgreSQL wire protocol, including CockroachDB Cloud with cluster routing

Everything on the [PostgreSQL](/databases/postgresql) page holds here. The same libpq driver serves both, out of the PostgreSQL plugin the app already ships, and no minimum cluster version is enforced. This page is only the differences.

<Frame caption="The CockroachDB connection form">
  <img className="block dark:hidden" src="https://mintcdn.com/ngquct-docs-fix-500-query-results/hA72m8tSnRe3b-ew/images/cockroachdb-connection-form.png?fit=max&auto=format&n=hA72m8tSnRe3b-ew&q=85&s=8531066f400c4ee32986c8711cc093b4" alt="CockroachDB connection form" width="1560" height="960" data-path="images/cockroachdb-connection-form.png" />

  <img className="hidden dark:block" src="https://mintcdn.com/ngquct-docs-fix-500-query-results/hA72m8tSnRe3b-ew/images/cockroachdb-connection-form-dark.png?fit=max&auto=format&n=hA72m8tSnRe3b-ew&q=85&s=cf3a4b49413c2b087a2c128356d869c2" alt="CockroachDB connection form" width="1560" height="960" data-path="images/cockroachdb-connection-form-dark.png" />
</Frame>

## Connection settings

| Field        | Default       | Notes                                                                                                       |
| ------------ | ------------- | ----------------------------------------------------------------------------------------------------------- |
| **Port**     | `26257`       | Not 5432                                                                                                    |
| **Database** | `defaultdb`   | Required. New clusters start with `defaultdb` and `postgres`, and only `system` is marked a system database |
| **Username** | -             | Not pre-filled. `root` on a local insecure cluster                                                          |
| **SSL Mode** | **Preferred** | TLS first, plain text if the server refuses                                                                 |

For a node started with `cockroach start-single-node --insecure`, set SSL Mode to **Disabled** and leave the password empty. Otherwise fill in the form and click **Save & Connect**.

## Connection URL

```text theme={null}
cockroachdb://user:password@host:26257/defaultdb
```

`cockroach://` also works. See [Connection URL Reference](/connections/urls).

## CockroachDB Cloud

A Cloud connection string carries a cluster routing parameter that the form has no field for. Copy the host, port, user, password, and database from the Cloud console, then put the routing value in **Connection Options** on the Advanced tab:

```text theme={null}
--cluster=my-cluster-1234
```

Set SSL Mode to **Verify Identity** for Cloud. **Connection Options** goes straight to libpq, so it takes any other libpq option a self-hosted cluster needs.

## What is different

Table and view DDL comes from CockroachDB's own `SHOW CREATE`, so the DDL tab shows the statement the cluster itself would emit rather than a reconstruction.

`EXPLAIN` and `EXPLAIN ANALYZE` render as a visual plan tree. CockroachDB returns text plans rather than JSON, and the text is parsed into the tree. See [EXPLAIN Visualization](/features/explain-visualization).

Changing database means reconnecting, as on PostgreSQL. A tab bound to a database other than the connection's active one runs on a separate connection for it, sharing no temp tables, session variables, or open transaction with the query editor. See [Cross-database tabs](/databases/postgresql#cross-database-tabs).

## Limitations

* No structure editing at all: no column changes, no index changes, no primary key changes. The Structure tab is read-only. Run schema changes as SQL in the editor.
* No `pg_dump` or `pg_restore`. **File > Backup Dump…** and **File > Restore Dump…** stay dimmed. Use CockroachDB's `BACKUP` and `RESTORE` statements.
* No Table Maintenance submenu. CockroachDB garbage-collects on its own and offers no `VACUUM` to run.
* Foreign key checks cannot be deferred.

## Troubleshooting

**Connection refused**: Check the cluster is running and port 26257 is reachable. For a local cluster, confirm `cockroach start` is still running.

**Authentication fails**: On a local insecure cluster use `root`, no password, and SSL Mode **Disabled**. On Cloud, copy the credentials from the console and use **Verify Identity**.

**Cloud connection hangs or is rejected**: The cluster routing value is missing. Put `--cluster=your-cluster-name` in **Connection Options**.

**EXPLAIN shows raw text**: The plan did not match the shape the parser expects, so it fell back to the server's own text. The plan is complete; only the tree is missing.
