Connect to AlloyDB
Connect AlloyDB to Retool to query data, manage records, and build apps, workflows, and agents with SQL.
AlloyDB is a fully managed, PostgreSQL-compatible database service from Google Cloud, built for demanding transactional and analytical workloads. You can create an AlloyDB resource to securely connect to your cluster and build apps, workflows, and agents that use SQL queries to perform create, read, update, and delete operations.
What you can do with AlloyDB in Retool
- Query data with SQL using joins, aggregations, subqueries, common table expressions (CTEs), window functions, and PostgreSQL-compatible functions using SQL mode.
- Insert, update, and delete records using GUI mode for write operations.
- Work with
JSONBcolumns, arrays, and other PostgreSQL-compatible data types. - Run scheduled AlloyDB queries in Retool Workflows.
- Build dashboards and apps that display AlloyDB query results in charts, tables, and other components.
Before you begin
To connect AlloyDB to Retool, you need the following:
- Cloud
- Self-hosted
- AlloyDB cluster: An accessible AlloyDB cluster with at least one instance available.
- Network access: Your AlloyDB instance must permit connections from Retool's IP addresses. AlloyDB instances are private by default — use a public IP or VPC peering to allow access.
- Credentials: A database username and password with appropriate permissions.
- Retool permissions: Ability to create and manage resources in your organization.
- AlloyDB cluster: An accessible AlloyDB cluster with at least one instance available.
- Network access: Your Retool instance must be able to reach your AlloyDB instance endpoint. AlloyDB instances are private by default — ensure network connectivity between your Retool deployment and your VPC.
- Credentials: A database username and password with appropriate permissions.
- Retool permissions: Ability to create and manage resources in your organization.
Create an AlloyDB resource
Follow these steps to create an AlloyDB resource in your Retool organization.
1. Create a new resource
In your Retool organization, navigate to Resources in the main navigation and click Create new → Resource. Search for AlloyDB and click the AlloyDB tile to begin configuration.

AlloyDB resource selection.
Use folders to organize your resources by team, environment, or data source type. This helps keep your resource list manageable as your organization grows.
2. Configure general settings
Specify a name and description for the resource that indicates which cluster or database it connects to. The description provides more context to users and Assist about how to use the resource.
| Example name | Example description |
|---|---|
Analytics DB | A read-only AlloyDB database for analytics and reporting. |
Production AlloyDB | The main AlloyDB cluster with customer and transaction data. |
3. Configure resource credentials
Configure the connection settings for your AlloyDB resource.

AlloyDB connection settings.
-
Host — The IP address or hostname of your AlloyDB instance. AlloyDB instances are assigned a private IP by default; use that IP or configure a public IP if connecting over the internet.
Examples10.10.0.2alloydb-primary.internal.example.com -
Port — The port number for your AlloyDB instance. AlloyDB uses PostgreSQL's default port
5432. -
Database name — The name of the database to connect to on your AlloyDB instance.
Exampleanalytics
4. Configure authentication
AlloyDB uses username and password authentication. Provide the database username and password for the account Retool should use to connect.
For sensitive values like passwords, use configuration variables or Retool secrets rather than hardcoding them.

AlloyDB authentication settings.
-
Database username — The username to authenticate with.
Exampleretool -
Database password — The password for the database user.
-
Use SSL/TLS — Enable this to encrypt the connection between Retool and your AlloyDB instance. When enabled, additional SSL configuration fields appear:
| Field | Description |
|---|---|
| SSL host | Override the hostname used for SSL certificate verification. Useful when connecting through proxies or load balancers. |
| Reject unauthorized | Reject connections if the server's SSL certificate cannot be verified. Enabled by default. |
| CA certificate | Your certificate authority (CA) certificate for SSL verification. |
| Client certificate and key | For mutual TLS (mTLS), provide a client certificate and private key. |
AlloyDB supports SSL/TLS connections and it is recommended for all connections, especially when using a public IP. Download your instance's CA certificate from the Google Cloud Console.
5. Configure advanced options
Configure optional settings available under the Advanced options section of the resource configuration form.
Outbound region
- Cloud
- Self-hosted
If your organization uses outbound regions, select the region that should be used for requests to AlloyDB. This controls which geographic region your requests originate from, which is useful for reducing latency or meeting data residency requirements.
Self-hosted instances do not have the outbound region field. Connections originate from your Retool instance's network.
Disable converting queries to prepared statements
By default, Retool uses prepared statements for AlloyDB queries, which improves performance and prevents SQL injection. Disable this option only if your AlloyDB setup does not support prepared statements (for example, when connecting through a connection pooler like PgBouncer in transaction mode).