Works on Digital Ocean but not Atlas or Baremetal

This has me scratching my head. With the exact same code in nodejs/mongoose my application can connect to Digital Ocean Managed db, Atlas and baremetal install on ubuntu. However only the Digital Ocean db returns any data when I run the application. Yes I have confirmed that all three db’s have the same data. The only thing different would be the connection strings. I have used a mongodb client to connect to all three db’s and confirm the connections string. I have five applications and they all have the same behaviour. I am trying to migrate to Atlas away from Digital Ocean. Any help would be appreciated.

Here is the environment:

  • Atlas v 6+
  • Digital Ocean 6+
  • Bare metal 7+

Mongoose 7.5.0
Nodejs 18+
Alpine 3.18

Here is the connection string used:


// -------  Start Mongo connection ---------------------------
mongoose.set("strictQuery", false);
const options = {
  useNewUrlParser: true,
  useUnifiedTopology: true,
  autoIndex: true,
  serverSelectionTimeoutMS: 5000, // Keep trying to send operations for 5 seconds
  family: 4, // Use IPv4, skip trying IPv6
};
if (process.env.NODE_ENV !== "prod") {
  mongoose.set("debug", (collectionName, method, query, doc) => {
    console.log(`${collectionName}.${method}`, JSON.stringify(query), doc);
  });
}

const mongo_url =  "redacted";

mongoose.connect(mongo_url, options);

const db = mongoose.connection;
db.once("open", () => console.log("Connected to Mongoose On DO"));
// listen for errors after the initial connection.
db.on("error", (error) => console.error(error));
db.on("disconnect", (error) => console.error(error));
// --------------- End Mongoose Connection -------------------

The authentication was wrong :frowning:

2 Likes

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