0

When starting up my application, I get the following warning:

(node:11800) DeprecationWarning: current Server Discovery and
Monitoring engine is deprecated, and will be removed in a future
version. To use the new Server Discover and Monitoring engine, pass
option { useUnifiedTopology: true } to the MongoClient constructor.

Yet we are specifying this value:

connection = await mongoose.connect(dbUrl, {
  keepAlive: true,
  useNewUrlParser: true,
  useCreateIndex: true,
  useFindAndModify: false,
  useUnifiedTopology: true
});

The value for dbUrl is: mongodb://localhost:27017/test-app

Environment:

  • mongo v4.0.13 on macOS
  • nodejs v10.15.3
  • package mongodb@3.3.2
  • package mongoose@5.7.0

Any ideas on how to deal with the warning?

Carlos Cavero
  • 3,011
  • 5
  • 21
  • 41
Andre M
  • 6,649
  • 7
  • 52
  • 93
  • I think this was discussed here: https://stackoverflow.com/questions/57895175/server-discovery-and-monitoring-engine-is-deprecated – Adam Harrison Oct 25 '19 at 19:11
  • Apart from the above mentioned link which has it all. You can try setting it explicity by `mongoose.set('useUnifiedTopology', true);` – ambianBeing Oct 25 '19 at 19:14
  • Turns out the issue was related to a piece of code in our tests that was using mongodb package directly, to drop the database. We needed to ensure the parameter was passed there. – Andre M Oct 27 '19 at 18:14

2 Answers2

1

This happens due to change in public ip address The only way that worked for me is by changing my public ip address inside mongodb atlas Go to cluster>network access>click on edit then change the ip address with your current public ip address

for checking you ip address type what is my public ip address on google and follow the first link

0

This works fine for me, and no more errors.

try this,

mongoose
    .connect(db,{
        useUnifiedTopology: true,
        useNewUrlParser: true,
        })
    .then(() => console.log('MongoDB Connected...'))
    .catch(err => console.log(err));
Chanu
  • 11
  • 2