Can't connect to MongoDB atlas serverless instance

Hi, i have a MongoDB serverless instance but i can't connect to that. 

I am using the connection string that mongo atlas gives me

but i get the following error:

"A TXT record is only permitted to contain the keys [authsource, replicaset], but the TXT record for '' contains the keys [loadbalanced, authsource]."

I don't know what could be happening, it's a serverless instance

Yuriy Vinogradov

Just found similar issue here
Looks like your server returns TXT record which contains 'loadbalanced' value, so I guess you need to contact support on server side to change DNS records.


Hello Guys,

Last Monday I have Facing same problem Please any one can Help me. Thanks in Advance.

’m trying to connect to an Atlas Serverless database from Nodejs. It just won’t work. Tried and triple checked everything I found. mongosh connect works, so user/passwd must be right, and ip whitelisting must work too. Portal

I followed MongoDB Atlas Serverless Instances: Quick Start to the letter, yet the insertOne fails with “MongoDriverError: MongoClient must be connected to perform this operation”.

Help please!


Hello!, Nicomorales297

I have same type problem 

So I'm currently wirting a web application and I need database so I decided to go with mongodb and mongoose. Until now I tested everything on localhost and it worked but I wanted to move the data to a server. I had heard of Atlas and registered myself and "uploaded" the data.

Now I want to connect to the cluster via a node.js app.


I got the string of the mongodb Atlas site at the point Connect Your Application

Then I swapped my password.


This didn't work either.

Thats the error message:

{ MongoError: failed to connect to server [] on first connect [MongoNetworkError: connect ECONNREFUSED]
at Pool.<anonymous> (U:\WEBT\ProjectInsight\Quiz\node_modules\mongodb-core\lib\topologies\server.js:503:11)
at emitOne (events.js:115:13)
at Pool.emit (events.js:210:7)
at Connection.<anonymous> (U:\WEBT\ProjectInsight\Quiz\node_modules\mongodb-core\lib\connection\pool.js:326:12)
at Object.onceWrapper (events.js:318:30)
at emitTwo (events.js:125:13)
at Connection.emit (events.js:213:7)
at TLSSocket.<anonymous> (U:\WEBT\ProjectInsight\Quiz\node_modules\mongodb-core\lib\connection\connection.js:245:50)
at Object.onceWrapper (events.js:316:30)
at emitOne (events.js:115:13)
at TLSSocket.emit (events.js:210:7)
at emitErrorNT (internal/streams/destroy.js:64:8)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
  name: 'MongoNetworkError',

message: 'failed to connect to server [] on first connect [MongoNetworkError: connect ECONNREFUSED]' } (node:4920) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): MongoNetworkError: failed to connect to server [] on first connect [MongoNetworkError: connect ECONNREFUSED] (node:4920) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. KohlsFeedback Survey

any one can help me 




I have had the same issue since I updated to the latest IntelliJ version 2022.2.

I have installed the previous version 2022.1.4 and there it works. That should indicate the problem does not come from the DNS. 

I have had success also connecting from mongosh and a python script from the same machine.


update mongodb lib to 4.1.0 +


Thanks for the updates.

We have an issue reported similar to yours:

Please try to update the Mongo DB driver to version 4.1.0 or higher:

Retry to connect, and let us know your results.

If the issue will remain, please find the idea log in Help - Show Log in FIles and upload it to:

I have had this same problem when trying to connect to Mongo Atlas with the currently latest version of DataGrip (2023.1.2)

When downgrading to 2022.1.5 I can connect without changing any settings. The problem thus seems to lie with DataGrip or possibly the JVM version it uses.


Please sign in to leave a comment.