4

I am trying to connect a MongoDB atlas instance to a nodejs/express server :

const mongoose = require("mongoose");

const dbURI =
 "mongodb+srv://(url copied from atlas connect)";

const options = {
  useNewUrlParser: true,
  dbName: "data"
};

mongoose.connect(dbURI, options).then(
 () => {
   console.log("Database connection established!");
 },
 err => {
   console.log("Error connecting Database instance due to: ", err);
 }
);

But I keep get the following error:

MongoNetworkError: connection 5 to cluster ... 27017 closes at TLSSocket. ...

How can I fix this?

hb22
  • 383
  • 1
  • 2
  • 14

1 Answers1

6

Resolved -- Check IP whitelist!

hb22
  • 383
  • 1
  • 2
  • 14