ATLAS Serverless and DNS txt record

I have created a serverless database which i should get connected with the proposed connection string:


Now, when i try to write on the database, i get the following error (from a lambda function):

MongoParseError: Text record must only set `authSource` or `replicaSet`

The mongodb source code seems to be looking for either authSource or ReplicaSet TXT dns records, whilst the connection string DNS returns:

"TXT    "authSource=admin&loadBalanced=true"

So my questions are:

  1. is serverless meant to work in a different way i.e. not via mongodb/mongoose
  2. how can i connect to the DB despite the loadBalanced=true string?



1 Like

I would also like to know this.

Check this link.It may help

This is me posting the question on SO :slight_smile:

I’ve opened the topic mentioned below on SO (amazon web services - atlas mongodb serverless and aws lambda connection issue - Stack Overflow), however i have not received any input. I am 99% sure that the issue lies with serverless databases, not with my code; I switched over to a regular M0 instance, and the code just works.

Maybe the serverless DB is only meant to be used via REST?

:grinning: ok

So you tried without loadbalanced?

hi, problem is: i don’t control the DNS, this is part of the service

I’m still stuck on this was well… but sadly I feel that there is no support of normal apps like mongoose as this time.
When using MongoDB Atlas’ Connect Wizard it mentions the the native MongoDB node.js driver 3.7+ doesn’t have the capability to handle serverless yet:
**This driver version is not supported for MongoDB Serverless.** Support for Serverless on this driver is coming soon.

Hi @Valerio_Merani ,

The issue that you were facing was likely due to the Node.js driver not supporting serverless instances yet (namely the lack of support for the loadBalanced configuration as pointed out by other community members).

We have just released version 4.1.0 of our Node.js driver, which supports serverless instances. You should now be able to upgrade your driver version to 4.1.0 and connect to your serverless instance!

You may separately have to wait for Mongoose to update their library in order to use Mongoose with serverless instances.

Hope this helps!
– Chris


This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.