Scale up as you grow — whether you're running one virtual machine or ten thousand.

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

Connected Tutorial(This question is a follow-up to this tutorial):
Making a Node + MongoDB App on DigitalOceanI went through the tutorial, from start to finish, have a Digital Ocean Managed Mongo DB created, and am beating my head against a wall trying to get Node to successfully connect to the database. This is my connection code (sensitive values have been obscured):
let cachedDb = null;
async function connectMongo() {
if (cachedDb) {
return cachedDb;
}
try {
const url = 'mongodb://doadmin:****************@db-mongodb-****-*****-********.mongo.ondigitalocean.com/admin?authSource=admin&replicaSet=db-mongodb-****-*****'
const client = await mongodb.connect(
process.env.DATABASE_URL, {
useNewUrlParser: true,
useUnifiedTopology: true,
// tls: true,
tlsCAFile: './ca-certificate.crt'
}
);
const db = client.db('nanocrowd');
cachedDb = db;
return db;
} catch(err) {
console.log(err);
throw(err);
}
}
When the code attempts a connection, the following error response is returned:
stack: 'MongoServerSelectionError: getaddrinfo ENOTFOUND db-mongodb-****-*****-********.mongo.ondigitalocean.com\n at Timeout._onTimeout (node_modules\\mongodb\\lib\\sdam\\topology.js:325:38)\n at listOnTimeout (internal/timers.js:554:17)\n at processTimers (internal/timers.js:497:7)'
I’m able to connect to the managed mongodb instance from my local development machine using two different clients: mongo, and Compass. Both connect using the identical parameters supplied to the NodeJS connection.
Does anyone have a working example that they’re willing to share?
Thanks in advance.
personal
7c31733a76c942f69d6186090a3787
antoine
Jamal
DriftingNavyFish
4a14ba3a148542cab1814465d54cbf
Mattia
SleepingAquamarineMantaRay
AI-LastWish
Marcos Lemos