Closed albertdugba closed 1 month ago
I always have this issue anytime, I try connecting my app to datahub. Dont know what am doing wrong but its not working. This is my error
Mongo connection Error: MongoServerSelectionError: getaddrinfo ENOTFOUND datahub at Timeout._onTimeout (/Users/Dugba/Desktop/origoproject/gazelle-shared-services/node_modules/mongodb/lib/core/sdam/topology.js:428:30) at listOnTimeout (internal/timers.js:549:17) at processTimers (internal/timers.js:492:7) { reason: TopologyDescription { type: 'Single', setName: null, maxSetVersion: null, maxElectionId: null, servers: Map(1) { 'datahub:27017' => [ServerDescription] }, stale: false, compatible: true, compatibilityError: null, logicalSessionTimeoutMinutes: null, heartbeatFrequencyMS: 10000, localThresholdMS: 15, commonWireVersion: null }, [Symbol(mongoErrorContextSymbol)]: {} }
AND this is my code
const mongo = require("mongodb"); const client = new mongo.MongoClient("mongodb://datahub:27017", { useUnifiedTopology: true, }); client .connect() .then(() => console.log("Connected to Mongo Database")) .catch(err => console.log("Mongo connection Error: ", err)); module.exports = client;
I always have this issue anytime, I try connecting my app to datahub. Dont know what am doing wrong but its not working. This is my error
AND this is my code