Database Connection

Connect a PowerSync Cloud instance to your backend database.

Create PowerSync Instance

  1. In the PowerSync dashboard project tree (PowerSync Cloud), click on "Create new instance":

  1. Give your instance a name, such as "Todolist Testing".

  2. Under the "General" tab, you can change the default cloud region from "US" to "EU" or "JP" if desired (more cloud regions are available, contact us if you need a different region).

  3. Under the "DB Connections" tab, click on the + icon.

Each provider has their quirks when it comes to specifying connection details, so we have documented provider-specific instructions below.

Connect PowerSync to Database

Select your provider for steps to connect your database to the newly created instance:

Supabase
  1. Get your connection details from Supabase:

  • In your Supabase dashboard, navigate to "Project Settings" -> "Database" -> "Connection string" and select the "URI" tab.

  • Uncheck the "Display connection pooler" checkbox. PowerSync needs to connect to the database directly and cannot use the pooler.

  • Copy the connection string. The hostname should be db.<PROJECT-ID>.supabase.co, and not, for example, aws-0-us-west-1.pooler.supabase.com.

  • Paste this URI into the connection URI field.

  • Enter the password for the postgres user in your Supabase database

  • PowerSync has the Supabase CA certificate pre-configured — verify-full SSL mode can be used directly, without any custom certificates.

  • If you want to query your database via the PowerSync dashboard, enable "Allow querying in the editor?".

  1. Click "Test Connection" and fix any errors.

  2. Under the "Client Auth" tab, enable "Use Supabase Auth".

  3. Click "Save".

PowerSync deploys and configures an isolated cloud environment for you, which will take a few minutes to complete.

Troubleshooting

Supabase is configured with a maximum of 4 logical replication slots, with one often used for Supabase Realtime.

It is therefore easy to run out of replication slots, resulting in an error such as "All replication slots are in use" when deploying. To resolve this, delete inactive replication slots by running this query:

select slot_name, pg_drop_replication_slot(slot_name) from pg_replication_slots where active = false;
AWS RDS
  1. Locate the connection details from RDS:

    • Copy the "Endpoint" value.

    • Paste the endpoint into the "Host" field.

    • Complete the remaining fields: "Name", "Host", "Port", "Database name", "Username", "Password" and "SSL Mode" are required. You can paste a connection string into the "URI" field to simplify this.

    • "Name" can be any name for the connection.

    • "Port" is 5432 for Postgres databases.

    • "Username" and "Password" maps to the powersync_role created in Source Database Setup.

    • PowerSync has the AWS RDS CA certificate pre-configured — verify-full SSL mode can be used directly, without any additional configuration required.

    • If you want to query your source database via the PowerSync dashboard, enable "Allow querying data from the dashboard?".

  2. Click "Test Connection" and fix any errors.

  3. Click "Save".

PowerSync deploys and configures an isolated cloud environment for you, which will take a few minutes to complete.

Troubleshooting

If you get an error such as "IPs in this range are not supported", the instance is likely not configured to be publicly accessible. A DNS lookup on the host should give a public IP, and not for example 10.x.x.x or 172.31.x.x.

Azure Postgres
  1. Fill in your connection details from Azure.

    1. "Name", "Host", "Port", "Database name", "Username", "Password" and "SSL Mode" are required. You can also paste a connection string into the "URI" field to simplify data entry.

    2. "Name" can be any name for the connection.

    3. "Port" is 5432 for Postgres databases.

    4. "Username" and "Password" maps to the powersync_role created in Source Database Setup.

    5. PowerSync has the Azure CA certificate pre-configured — verify-full SSL mode can be used directly, without any additional configuration required.

    6. If you want to query your source database via the PowerSync dashboard, enable "Allow querying data from the dashboard?".

  1. Click "Test Connection" and fix any errors.

    • If you encounter the error "must be superuser or replication role to start walsender", ensure that you've followed all the steps for enabling logical replication documented here.

  2. Click "Save".

PowerSync deploys and configures an isolated cloud environment for you, which will take a few minutes to complete.

Google Cloud SQL
  1. Fill in your connection details from Google Cloud SQL.

    • "Name", "Host", "Port", "Database name", "Username", "Password" and "SSL Mode" are required. You can paste a connection string into the "URI" field to simplify data entry.

    • "Name" can be any name for the connection.

    • "Port" is 5432 for Postgres databases.

    • "Username" and "Password" maps to the powersync_role created in Source Database Setup.

    • The server certificate can be downloaded from Google Cloud SQL.

    • If SSL is enforced, a client certificate and key must also be created on Google Cloud SQL, and configured on the PowerSync instance.

    • If you want to query your source database via the PowerSync dashboard, enable "Allow querying data from the dashboard?".

  1. Click "Test Connection" and fix any errors.

  2. Click "Save".

PowerSync deploys and configures an isolated cloud environment for you, which will take a few minutes to complete.

Neon
  1. Fill in your connection details from Neon.

    1. "Name", "Host", "Port", "Database name", "Username", "Password" and "SSL Mode" are required. You can paste a connection string into the "URI" field to simplify data entry.

    2. "Name" can be any name for the connection.

    3. "Port" is 5432 for Postgres databases.

    4. "Username" and "Password" maps to the powersync_role created in Source Database Setup.

    5. Note that if you're using a self-signed SSL certificate for your database server, click the "Download Certificate" button to dynamically fetch the recommended certificate directly from your server.

    6. Also note if you get any error such as server certificate not trusted: SELF_SIGNED_CERT_IN_CHAIN, click "Download Certificate" to attempt automatic resolution.

    7. If you want to query your source database via the PowerSync dashboard, enable "Allow querying data from the dashboard?".

  1. Click "Test Connection" and fix any errors.

  2. Click "Save".

PowerSync deploys and configures an isolated cloud environment for you, which will take a few minutes to complete.

Fly Postgres
  1. Fill in your connection details from Fly Postgres.

    1. "Name", "Host", "Port", "Database name", "Username", "Password" and "SSL Mode" are required. You can paste a connection string into the "URI" field to simplify data entry.

    2. "Name" can be any name for the connection.

    3. "Port" is 5432 for Postgres databases.

    4. "Username" and "Password" maps to the powersync_role created in Source Database Setup.

    5. Note that if you're using a self-signed SSL certificate for your database server, click the "Download Certificate" button to dynamically fetch the recommended certificate directly from your server.

    6. Also note if you get any error such as server certificate not trusted: SELF_SIGNED_CERT_IN_CHAIN, click "Download Certificate" to attempt automatic resolution.

    7. If you want to query your source database via the PowerSync dashboard, enable "Allow querying data from the dashboard?".

  1. Click "Test Connection" and fix any errors.

  2. Click "Save".

PowerSync deploys and configures an isolated cloud environment for you, which will take a few minutes to complete.

For other providers and self-hosted databases:

Other / Self-hosted
  1. Fill in your connection details.

    1. "Name", "Host", "Port", "Database name", "Username", "Password" and "SSL Mode" are required. You can paste a connection string into the "URI" field to simplify data entry.

    2. "Name" can be any name for the connection.

    3. "Port" is 5432 for Postgres databases.

    4. "Username" and "Password" maps to the powersync_role created in Source Database Setup.

    5. Note that if you're using a self-signed SSL certificate for your database server, click the "Download Certificate" button to dynamically fetch the recommended certificate directly from your server.

    6. Also note if you get any error such as server certificate not trusted: SELF_SIGNED_CERT_IN_CHAIN, click "Download Certificate" to attempt automatic resolution.

    7. If you want to query your source database via the PowerSync dashboard, enable "Allow querying data from the dashboard?".

  1. Click "Test Connection" and fix any errors.

  2. Click "Save".

PowerSync deploys and configures an isolated cloud environment for you, which will take a few minutes to complete.

Last updated