Scala Driver 2.9.0 connection fails with LoadBalancerSupportMismatch

I am using:
“org.mongodb.scala” %% “mongo-scala-driver” % “2.9.0”,

Connecting to a local mongodb works just fine but fails when trying to access Atlas with the following error:

{“ok”: 0, “errmsg”: “The server is being accessed through a load balancer, but this driver does not have load balancing enabled”, “code”: 354, “codeName”: “LoadBalancerSupportMismatch”}

My connection code is simple:
val mongoUri = “mongodb+srv://”
val mongoClient: MongoClient = MongoClient(mongoUri)
val database: MongoDatabase = mongoClient.getDatabase(mongoDBName)

The same connection string works fine from Nodejs

Actually the above error comes from using the older connection string format. With the above format I get this error:

com.mongodb.MongoConfigurationException: A TXT record is only permitted to contain the keys [authsource, replicaset], but the TXT record for ‘’ contains the keys [loadbalanced, authsource]


The 2.9.0 Scala driver is pre loadbalancer support. Please upgrade to the latest Scala driver 4.3.2.



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