Skip to main content

Connect to MongoDB

You can connect to MongoDB and make it available as a resource. Once complete, you can write queries to interact with MongoDB.

Retool supports connecting to both managed and self-hosted MongoDB databases, including MongoDB Atlas Clusters and AWS DocumentDB. Retool uses version 4.1 of the MongoDB Node driver.


All users for Retool organizations on Free or Team plans have global Edit permissions and can add, edit, and remove resources. If your organization manages user permissions for resources, you must be a member of a group with Edit all permissions.

To create your MongoDB resource, you need to know:

  • Your MongoDB host.
  • The connection format you want to use (Standard or DNS seed list).
  • The Mongo version your database uses.

The connection format you choose determines the fields required to create the resource. You might also need a port number, default database, a username, and a password.

If MongoDB is behind a firewall, you must also allow access from Retool's IP addresses. Add these IP addresses to your firewall's allowlist before you create the resource.

1. Create a MongoDB resource

Retool can connect to almost any API or database, and has built-in integrations for popular data sources. Sign in to your Retool organization and create a new MongoDB resource from the Resources tab.

2. Configure the resource

Provide the necessary details to configure the resource so Retool can connect to MongoDB. Not all settings are required but refer to the MongoDB documentation to learn what is needed.


These settings configure the name and location of the resource within Retool.


The name to use for the resource (e.g., MongoDB).


The folder in which to save the resource.


A brief description of the resource (e.g., Customer data).


These settings configure how Retool connects to MongoDB. You can configure the credentials manually or with a connection string.

HostThe URL or IP address.
Connection formatThe connection format used to connect to MongoDB. Options include Standard (/data-sources/quickstarts/database/mongodb) and DNS seed list (/data-sources/quickstarts/database/mongodb+srv).
PortThe port number. Only required when using the Standard (/data-sources/quickstarts/database/mongodb) connection format.
Default databaseThe name of the default database.
Database usernameYour database username.
Database passwordThe password of the database user.
Mongo versionThe range of supported MongoDB versions.
Connection optionsAdditional options for the MySQL connection.
Use SSL/TLSConnect to your database with SSL/TLS.

Advanced options

You can also configure the following advanced settings for MongoDB resources.

Disable converting queries to prepared statementsThis disables SQL injection protection to allow dynamically generated SQL using JavaScript.
SSH tunnelEnable SSH tunneling through bastion host.

3. Save the resource

Click Create resource to complete the setup. You can then click either Create an app to immediately start building a Retool app or Back to resources to return to the list of resources.

Wrap up

Your MongoDB resource is now ready to use. To interact with MongoDB data, select the resource in the query editor. Retool supports v2 of MongoDB's Extended JSON syntax.