Docs Menu

Docs HomeMongoDB Kafka Connector

Connect to MongoDB

On this page

  • Overview
  • How to Connect
  • How to Configure Your Connection
  • Authentication

Learn how to connect the MongoDB Kafka Connector to MongoDB using a connection Uniform Resource Identifier (URI). A connection URI is a string that contains the following information:

  • The address of your MongoDB deployment required

  • Connection settings optional

  • Authentication settings optional

  • Authentication credentials optional

The following is an example of a connection URI for a MongoDB replica set:


To learn more about the connection URI format, see Connection String URI Format in the MongoDB Manual.

Specify a connection URI with the following configuration option in both a source and sink connector:

connection.uri=<your connection uri>

To learn more about this configuration option, see the following resources:

The MongoDB Kafka Connector uses the MongoDB Java driver to parse your connection URI. The MongoDB Java driver is an artifact that enables Java applications like Kafka Connect to interact with MongoDB.


Driver Version

Version 1.3 of the MongoDB Kafka Connector uses version 3.11 or 3.12 of the MongoDB Java driver.

To learn what connection URI options are available in the MongoDB Kafka Connector, see the MongoDB Java driver Connection tutorial.

All authentication mechanisms available in the MongoDB Java driver are available in the MongoDB Kafka Connector.

The following is an example of a connection URI that authenticates with MongoDB using SCRAM-SHA-256 authentication:



Load Secrets

To avoid storing your authentication secrets as plain text in your connection.uri setting, load your secrets from a secure location as your connector starts. To learn how to load your secrets as your connector starts, see the Externalize Secrets guide from Confluent.

To learn what authentication mechanisms are available, see the MongoDB Java driver Authentication tutorial.

To learn more about authentication in the MongoDB Kafka Connector, see the Security and Authentication guide.

←  Install the MongoDB Kafka ConnectorData Formats →