# Database connections

> Store how to reach a database in each environment, encrypted, test it from Architure's servers, and sync its schemas into the design.

Source: https://docs.architure.dev/docs/database-connections

A database designed in Architure usually exists somewhere too: a production database, a preview branch, a local one. A database connection records how to reach it in each environment, so Architure can test it and [sync](/docs/schema-sync) its live schemas into the design. Each [database](/docs/databases) holds one connection URL per scope: **All**, **Production**, **Preview** and **Development**, the same scopes as [environment variables](/docs/environment-variables). The URL is encrypted on Architure's servers, and Architure never writes to the live database.

## Adding a connection

Open the database's canvas and choose **Connections** in the top bar; its count is the number of connections. The **Connections of** dialog lists them, then a form: pick a **Scope** among those still free, paste the **Connection URL** and choose **Save and test**:

- PostgreSQL: `postgres://user:password@host:5432/database`, with `?sslmode=require` to encrypt the connection or `?sslmode=verify-full` to also check the server's certificate.
- MySQL: `mysql://user:password@host:3306/database`, with `?ssl-mode=required` or `?ssl-mode=verify_identity`.

The URL must match the database's dialect. Each scope holds one connection; delete it to replace it. The test connects from Architure's servers and runs `select 1`; a failed test still saves the URL.

## The list of connections

Each row shows the scope, the URL hidden behind dots, and the last test: **Connected**, **Failed** with the driver's message under the row, or **Not tested**, with when it ran. On the row:

- the eye reveals the URL and hides it again, and the copy button copies it;
- **Sync…** opens the [schema sync](/docs/schema-sync);
- the refresh button tests the connection again;
- the bin deletes the connection, at once.

Tests are limited to ten a minute per organization.

## Syncing schemas

**Sync…** on a connection's row reads the live database through that connection and brings the design in line with it: you choose the live schemas, review a preview (**New**, **Changed**, **Only in Architure**), then **Apply changes** as one undoable edit. The read runs the [catalog query](/docs/import) in a read-only transaction and counts against the ten tests a minute. See [Schema sync](/docs/schema-sync).

## What is protected

- **Encryption.** URLs are encrypted with the server's secrets key, like environment variable values.
- **Public addresses only.** Before connecting, Architure resolves the host and refuses loopback, link-local (including cloud metadata addresses), private, unique-local, carrier-grade NAT and multicast addresses, then connects to the address it checked. A database inside a private network cannot be tested.
- **Reads only.** A test runs `select 1`. A sync runs the catalog query in a read-only transaction, with a 30-second limit, and keeps nothing of what it read but the changes you apply. Nothing is ever written to the live database.
- **Allow lists.** A database that accepts only known addresses must allow Architure's servers, or the test fails with a timeout.

## Who can see and change connections

Owners, admins and members add, reveal, test, sync and delete connections. Viewers do not see the **Connections** button, and agents never get the URLs: no MCP tool reads them.

Like every write, saving, testing, syncing and deleting need an active trial or subscription. While the organization is read-only (see [Billing and trial](/docs/billing)), the dialog still lists and reveals the connections, without the form and the row buttons.
