Skip to main content

MongoDB Connection

The MongoDB connection type enables automations to query, insert, update, and delete documents in MongoDB databases. It is used by the plugin-nosql-databases plugin, which delegates to the nosql-database-connector.

Connection Type

PropertyValue
Type enumMONGODB
Type IDmongodb
CategoryDatabase
Entity classNoSQLDBConnectionDetails

Friendly Example

What you enterExample
Connection nameMongoDB - Customer Records
Used forReading or updating approved document data for workflows
Main details to collectConnection string, database name, username, and password
Best person to provide itDatabase administrator

After it is saved, workflow builders select MongoDB - Customer Records in a node instead of entering these details again.

Mandatory Fields

FieldTypeRequiredDescription
databaseDatabaseTypeYesSet to MONGODB (or the appropriate NoSQL database type if using a different engine through the same connector).
jdbcUrlStringYesMongoDB connection string URI. Despite the field name, this accepts a standard MongoDB URI (see format below).
usernameStringYesMongoDB authentication username.
passwordStringYesMongoDB authentication password. Encrypted at rest.

Advanced Fields

FieldTypeRequiredDescription
portStringNoMongoDB port. Defaults to 27017. This is typically included in the connection URI but can be specified separately.

Connection String Format

The jdbcUrl field accepts a standard MongoDB connection URI:

Standard Format (Standalone or Replica Set)

mongodb://host1:27017,host2:27017,host3:27017/databaseName?replicaSet=myReplicaSet&authSource=admin

SRV Format (Atlas and DNS-based discovery)

mongodb+srv://cluster0.abcdef.mongodb.net/databaseName?retryWrites=true&w=majority

Common URI Parameters

ParameterDescriptionExample
authSourceDatabase used for authentication. Defaults to admin.authSource=admin
replicaSetReplica set name. Required for replica set connections when not using SRV.replicaSet=rs0
sslEnable TLS/SSL.ssl=true
tlsAlias for ssl. Preferred in newer drivers.tls=true
tlsAllowInvalidCertificatesSkip certificate validation. Not recommended for production.tlsAllowInvalidCertificates=true
retryWritesEnable retryable writes.retryWrites=true
wWrite concern.w=majority
maxPoolSizeMaximum connection pool size.maxPoolSize=50
connectTimeoutMSConnection timeout in milliseconds.connectTimeoutMS=10000
info

The username and password can be included in the URI (mongodb://user:pass@host/db) or provided separately in the username and password fields. When provided separately, they take precedence. Using the separate fields is recommended because the password will be encrypted at rest by the Global Configurator.

Setup Instructions

  1. Create a dedicated MongoDB user for automation use:

    use admin
    db.createUser({
    user: "qinfinite_automation",
    pwd: "strong-password",
    roles: [
    { role: "readWrite", db: "target_database" }
    ]
    })

    For read-only access, use the read role instead of readWrite.

  2. Ensure network connectivity. The MongoDB port (default 27017) must be reachable from the Qinfinite platform. For MongoDB Atlas, add the platform's IP addresses to the Atlas IP Access List.

  3. Construct the connection URI with the appropriate hosts, database name, and options.

  4. Create the connection in the Global Configurator.

  5. Test the connection to verify credentials and network access.

Troubleshooting

SymptomLikely Cause
Connection refusedMongoDB is not running on the specified host/port, or a firewall is blocking access
Authentication failedWrong username, password, or authSource. Verify the user exists in the authentication database.
not authorized on [db] to execute commandThe user does not have the required role on the target database
MongoTimeoutExceptionNetwork connectivity issue, or the connection URI has unreachable hosts
SSL handshake failedTLS is required by the server but not enabled in the URI, or certificate validation failed