You can easily connect to your MongoDB cluster from your application using the Connection String provided on your Cluster Details page.
The Connection String is built in the following format:
For more details on connection strings in MongoDB, check out their official documentation.
The easiest way to build the right Connection String will be to copy the default Connection String provided on the ScaleGrid console and replace the username, password, and database fields with the correct values.
Here is an example of a Connection String for a replica set without SSL enabled. In this example, we use the credentials of user 'testuser' to connect to the database 'test'. The user must have access to the database to be able to connect.
ScaleGrid MongoDB SSL enabled clusters can be identified by the SSL icon on the Overview tab of the Cluster Details page:
Our MongoDB clusters are configured with self-signed certificates by default. The SSL CA certificate is available for download on the Overview page.
Most MongoDB drivers will provide an option to specify a CA certificate file. You can download the file from the ScaleGrid console and store it on your application servers. If your driver doesn't provide an option to specify the CA certificate file, attempts to establish SSL connections to a MongoDB server with self signed certificates might fail. In order to fix this, look for an option that lets you disable certificate validation on your driver/platform.
Follow these ScaleGrid posts for examples on connecting to SSL enabled MongoDB clusters:
Updated about 1 year ago