Auth0 Home Blog Docs

Custom database connect to MongoDB Cloud Atlas

custom-database

#1

I was able to set up a custom database connection and manage my users by creating an Azure Cosmos DB (mongodb). I attempted to connect to a MongoDB Cloud Atlas cluster, but I had no success. I believe it has something to do with the version of the NodeJS driver used, but I’m not familiar enough to know what questions to ask or how to troubleshoot.

The MongoDB Cloud Atlas offers two example connection strings, based on the driver version being used, but neither seem to work for me.

Using Driver 3.6 or later:

Connection string example:
mongodb+srv://myuser:userpass@clustername.mongodb.net/dbname?retryWrites=true

Error message received:
[SandboxUnhandledError] unknown mongodb+srv://myuser:userpass@clustername.mongodb.net/dbname?retryWrites=true config

Using Driver 3.4 or earlier:

Connection string example:
mongodb://myuser:userpass@clustershardname.mongodb.net:27017,clustershardname.mongodb.net:27017,clustershardname.mongodb.net:27017/dbname?ssl=true&replicaSet=clustershardname&authSource=admin&retryWrites=true

Error message received:
[Error] Error: Client request error: socket hang up

Has anyone has success connecting their Custom Database to MongoDB Cloud Atlas cluster?