> ## Documentation Index
> Fetch the complete documentation index at: https://midplane.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Connection problems

> What each message the connect form and a source's page show means, and what to do about it.

Each heading is a message the control room shows, shortened. Midplane never
shows the database's own error, which can quote your host, user or
password: it says which kind of failure it was.

## The connection string

### The connection string does not parse

The form reads the string as you type and says what stops it:

| It says | Fix |
| - | - |
| That isn't a connection string | Start with `postgres://`, `postgresql://` or `mysql://` (a `jdbc:` prefix is fine). |
| …names no host, or several hosts | Give one host after the `@`: the primary, or better, a replica. |
| …points at a Unix socket | Give the host name the database listens on. |
| The port isn't a number | Use 1 to 65535. |
| …names no user | Add the user before the `@`. |
| Name the database | End a MySQL string with `/<database>`. |
| Part of the connection string couldn't be read | Percent-encode `@ : / ? # %` in the user, password and database (`@` is `%40`). |

### Midplane connects to Postgres and MySQL for now

The string names another engine. Ask for it with **Request a source** on
**Sources**.

## Reaching the database

### The database did not answer

Nothing answered within 10 seconds, the connection was refused, or the
host name didn't resolve.

* Check the host and port, and that any firewall or security group allows
  your region's [egress addresses](https://midplane.ai/docs/connect/allowlist.md).
* A private database, or a name that resolves only inside your network,
  needs an [SSH bastion](https://midplane.ai/docs/connect/ssh.md): RDS unless publicly accessible,
  and Fly Managed Postgres always ([Fly](https://midplane.ai/docs/hosts/fly.md)).
* A Neon compute that scaled to zero wakes on the first try: **Test again**.

### The database does not offer TLS

Midplane connects only over TLS, whatever `sslmode` says. Turn TLS on in
the database: on your own Postgres, `ssl = on` with a certificate and key
([your own server](https://midplane.ai/docs/hosts/self-hosted.md)).

### The secure connection failed

TLS failed other than on the certificate: no shared version (Midplane needs
TLS 1.2 or later), the server wants a client certificate (Midplane presents
none), or something in front of the database doesn't speak TLS.

### The database certificate did not verify

The source needs a verified certificate: its string asks for one, or it
verified before ([how Midplane decides](https://midplane.ai/docs/connect/tls.md#how-midplane-decides)).

* Paste the CA that signed it, in the form or under **Credentials**
  ([get it verified](https://midplane.ai/docs/connect/tls.md#get-it-verified)).
* Connect by the name on the certificate, not an IP address or alias, even
  through a bastion.
* To accept a new source unverified, take `verify-ca` or `verify-full`
  (MySQL `VERIFY_CA`, `VERIFY_IDENTITY`) out of the string. A source that
  verified once can't go back.

## Signing in

### The database refused that user or password

* Check them, percent-encoded (`@` is `%40`). Use a password, not an
  expiring token such as RDS IAM's.
* The user is `postgres.<project ref>` on Supabase's pooler,
  `<role>.<branch id>` on PlanetScale Postgres.
* Postgres needs a `hostssl` line in `pg_hba.conf` for this user
  ([allowlists](https://midplane.ai/docs/connect/allowlist.md)), and no client certificate required.
* On MySQL, a partly run role script leaves its account locked: run it
  whole again. A user without access to the database is refused too.

### The database named in the connection string does not exist

Check the name after the last `/`, as the server spells it. With none,
Postgres uses the database named like the user. Hosts make one:
`postgres` on Supabase, `neondb` on Neon.

### Midplane needs a newer MySQL

Midplane checks every MySQL query's plan with `EXPLAIN` format 2, which
MySQL added in 8.3. It refuses MySQL 8.2 and older, Aurora MySQL (version 3
is MySQL 8.0) and MariaDB. Upgrade to MySQL 8.4, or connect a replica that
runs it; for MariaDB, use **Request a source**.

## SSH bastions

### The SSH bastion did not answer

Check **Bastion host** and **Port**, that its SSH server runs, and that its
firewall lets your region's [egress addresses](https://midplane.ai/docs/connect/allowlist.md) in.

### The SSH bastion refused the Midplane key

* Add the form's line to `~/.ssh/authorized_keys` of the user in **User**
  ([SSH bastions](https://midplane.ai/docs/connect/ssh.md)).
* `~/.ssh` must be `700` and the file `600`, owned by that user.
* Some systems refuse key logins to an account whose password is locked.
* OpenSSH before 7.2 doesn't know `restrict` and skips the line.

### The SSH bastion host key changed

The bastion's host key isn't the one Midplane pinned
([the pinned host key](https://midplane.ai/docs/connect/ssh.md#the-pinned-host-key)). If you didn't
replace the bastion or its keys, something else may be answering. If you
did, remove the source and connect it again with a new key, then review it
and set its access again: a source's bastion can't be changed yet.

### The SSH bastion could not reach the database

* Check the bastion resolves and reaches the connection string's host and
  port (`nc -vz db.internal 5432` on the bastion).
* `sshd_config` must allow `AllowTcpForwarding`, and any `PermitOpen` must
  include the database.
* The line's `permitopen` must match the string's host and port: copy it
  again after changing the string.

## The role

### The role cannot log in yet

Midplane couldn't log in as the role the latest script makes.

* Run the latest script, whole, in the source's database
  ([the role script](https://midplane.ai/docs/connect/role.md)).
* On a read replica, wait for the role to arrive from the primary, then
  switch again.
* If `pg_hba.conf` names users, add the role.
* On PlanetScale Postgres, use a dashboard role instead
  ([PlanetScale](https://midplane.ai/docs/hosts/planetscale.md)).

### Make the role script first

No role is waiting: none was made, or the source already switched to it.
Select **Make the script**.

## Credentials and names

### That connection string names another database

**Credentials** replaces the user or password for the same engine, host,
port and database, since the review and access were made for it. Connect
another database as a new source.

### The CA certificate could not be read

Paste it as PEM text, `-----BEGIN CERTIFICATE-----` and `-----END
CERTIFICATE-----` included. Convert a binary `.der` or `.cer` with
`openssl x509 -inform der -in ca.cer -out ca.pem`.

### A source with that name exists

Give this source another **Name**.

### There is no such source in this workspace

Someone removed it, or you are in another workspace. Open **Sources**.

### The connection test failed

Something else: the server had too many connections, was starting or
stopping, or wouldn't show its catalog. **Test again**. If it lasts, check
the database's log; on Postgres, Midplane's connections set
`application_name` to `midplane`.

## What a source shows

### A source is not answering

A failed test, query or catalog read (every 5 minutes) marks it **Not
answering**, with one of the sentences above; agents asking it are told
the same. Fix what it names, then **Test again**.

### Encrypted, not verified

TLS, but the certificate didn't verify: unknown authority, self-signed,
the wrong name or expired ([get it verified](https://midplane.ai/docs/connect/tls.md#get-it-verified)).

### Role can do more than read

The user Midplane connects as could write or change the database, though
Midplane still only reads. Run [the role script](https://midplane.ai/docs/connect/role.md), or use
your host's read-only user
([when you cannot run the script](https://midplane.ai/docs/connect/role.md#when-you-cannot-run-the-script)).
After a switch, what's left is named, such as `public` on
[Postgres 14 and older](https://midplane.ai/docs/connect/role.md#postgres-14-and-older).

### The role has not been checked yet

The role check didn't finish (a failing check warns of nothing rather than
failing the connection). **Test again**.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.