hb22
hb22

Reputation: 383

Node.js and MongoDB Atlas Mongoose Connection Error

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?

Upvotes: 4

Views: 2251

Answers (1)

hb22
hb22

Reputation: 383

Resolved -- Check IP whitelist!

Upvotes: 6

Related Questions