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?

2
  • What version of mongoose are you using? Commented Oct 1, 2018 at 4:15
  • @jman93 version 5.3.0 Commented Oct 1, 2018 at 5:43

1 Answer 1

6

Resolved -- Check IP whitelist!

Sign up to request clarification or add additional context in comments.

2 Comments

so glad you answered your question. solved my issue.
It works for dynamics IP too? My IP change every 12 hours

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.