Connect to a database

Retool connects to most databases, including PostgreSQL, MySQL, MS SQL, and MongoDB. Here's a list of all the currently supported data sources.

The connection details required by Retool depend on the type of database you want to connect. This information generally includes a host, port, user credentials, and connection string. Refer to your database's configuration or documentation to obtain this.

1. Allow Retool's IP addresses

Add Retool's IP addresses to your database's allowlist so that Retool can connect to your database.

52.177.12.28/32
52.175.251.223/32
35.90.103.132/30
44.208.168.68/30

If you aren't sure where to add these IP addresses, refer to your database's documentation.

2. Create a database resource

Resources represent connections to data sources and are what you query within your Retool apps. Log in to Retool and navigate to the Resources tab. Click Create new > Create a new resource and select the database you want to connect to. This opens the Connect a resource page where you add your connection information.

Adding a PostgreSQL resourceAdding a PostgreSQL resource

After you enter your connection details, click Test Connection to check Retool can successfully connect. Once complete, click Create resource to save the resource, then click Create an app to start building a new app.

If the connection fails, verify your connection details are correct and that you added Retool's IP addresses to your allowlist.

3. Query your database

In the App editor, update query1 to retrieve some information from a table in your database.

Editing query1Editing query1

Click Save & Run. Query results are automatically displayed after the query completes.


Did this page help you?