# MongoDB Connection issue with load balancer and driver incompatibility

**URL:** <https://community.auth0.com/t/mongodb-connection-issue-with-load-balancer-and-driver-incompatibility/105273>\
**Category:** Get Help\
**Tags:** custom-database-connections, connections\
**Created:** [April 21, 2023, 10:47pm UTC](https://community.auth0.com/t/mongodb-connection-issue-with-load-balancer-and-driver-incompatibility/105273 "2023-04-21T22:47:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![shaswat607](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/shaswat607/32/46221_2.png) [@shaswat607](https://community.auth0.com/u/shaswat607)\
**Post date:** [April 21, 2023, 10:47pm UTC](https://community.auth0.com/t/mongodb-connection-issue-with-load-balancer-and-driver-incompatibility/105273/1 "2023-04-21T22:47:10Z")

</div>

All the methods are running into the error - `The server is being accessed through a load balancer, but this driver does not have load balancing enabled`

Following is my `create` script. Any help is appreciated here.

```auto
function create(user, callback) {
  const bcrypt = require('bcrypt');
  const MongoClient = require('mongodb@3.1.4').MongoClient;
  const client = new MongoClient('mongodb+srv://user:pass@cluster.ems0gvj.mongodb.net/?retryWrites=true&w=majority');

  client.connect(function (err) {
    if (err) return callback(err);

    const db = client.db('auth0-dev');
    const users = db.collection('users');

    users.findOne({ email: user.email }, function (err, withSameMail) {
      if (err || withSameMail) {
        client.close();
        return callback(err || new Error('the user already exists'));
      }

      bcrypt.hash(user.password, 10, function (err, hash) {
        if (err) {
          client.close();
          return callback(err);
        }

        user.password = hash;
        user.email_verified = false;
        users.insert(user, function (err, inserted) {
          client.close();

          if (err) return callback(err);
          callback(null);
        });
      });
    });
  });
}

```

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [April 25, 2023, 12:48pm UTC](https://community.auth0.com/t/mongodb-connection-issue-with-load-balancer-and-driver-incompatibility/105273/3 "2023-04-25T12:48:01Z")

</div>

Hi @shaswat607,

It looks like you are using an older version of the `mongodb` node client. Can you try upgrading to see if it solves the issue?

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [June 16, 2023, 1:21pm UTC](https://community.auth0.com/t/mongodb-connection-issue-with-load-balancer-and-driver-incompatibility/105273/4 "2023-06-16T13:21:40Z")

</div>

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