MongoDB Custom Database Connection Error

Problem statement

We have created a serverless Mongodb Cluster and trying to connect in Custom Database script but are getting the following error:

[MongoError] 354 - The server is being accessed through a load balancer, but this driver does not have load balancing enabled.

Solution

Update the mongodb Node JS driver to a supported version as described by the Atlas Serverless documentation (> 4.1.0)