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

If your database uses an inbound firewall, follow instructions to add Retool's IP addresses to your database's allowlist so Retool can connect to your database.

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 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 query1

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

If you entered a Database name when you created your resource, you can use the schema browser to inspect your database schema. Table and column names also auto-populate in the query editor when this introspection is enabled.

What’s Next