Connection problem

Hello, I have problem connecting my new domain to mongoDB on other domain everything working fine.
Currently in my accesslist I have added

But even with this im still getting error:

MongooseServerSelectionError: Could not connect to any servers in your MongoDB Atlas cluster. One common reason is that you're trying to accessthe database from an IP that isn't whitelisted. Make sure your current IP address is on your Atlas cluster's IP whitelist:
    at NativeConnection.Connection.openUri (/home/cryptojo/nodevenv/marketserver/14/lib/node_modules/mongoose/lib/connection.js:825:32)
    at /home/cryptojo/nodevenv/marketserver/14/lib/node_modules/mongoose/lib/index.js:414:10
    at /home/cryptojo/nodevenv/marketserver/14/lib/node_modules/mongoose/lib/helpers/promiseOrCallback.js:41:5
    at new Promise (<anonymous>)
    at promiseOrCallback (/home/cryptojo/nodevenv/marketserver/14/lib/node_modules/mongoose/lib/helpers/promiseOrCallback.js:40:10)
    at Mongoose._promiseOrCallback (/home/cryptojo/nodevenv/marketserver/14/lib/node_modules/mongoose/lib/index.js:1288:10)
    at Mongoose.connect (/home/cryptojo/nodevenv/marketserver/14/lib/node_modules/mongoose/lib/index.js:413:20)
    at Object.<anonymous> (/home/cryptojo/marketserver/app.js:55:4)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10) {
  reason: TopologyDescription {
    type: 'ReplicaSetNoPrimary',
    servers: Map(3) {
      '' => [ServerDescription],
      '' => [ServerDescription],
      '' => [ServerDescription]
    stale: false,
    compatible: true,
    heartbeatFrequencyMS: 10000,
    localThresholdMS: 15,
    setName: 'atlas-vffn0h-shard-0',
    maxElectionId: null,
    maxSetVersion: null,
    commonWireVersion: 0,
    logicalSessionTimeoutMinutes: null
  code: undefined

and my app.js on end have:

  .connect(process.env.DB, { useNewUrlParser: true })
  .then(() => {
    initSocket(http, corsOptions); 
  .catch((err) => console.log(err));

and my env file looks like:
DB = 'mongodb+srv://'

So localy everything working fine, I have even get compas desktop application and with same string it was succesfull.

Best regards

Hello, you solve it? I have almost the same issue with my project, it gives an error with the whitelist and I whitelisted everything yet when it runs locally is just fine even when I have my VSC open and runs the main script “npm run start” from the server and Front runs on my desktop the URL, but when stop de npm, starts to lose the DB connection.

Hello, I have solved this I had to contact a support of my hosting so they can open a port 27017 so the connection to mongoDB is succesfull.

1 Like

Hello, did you sort out your case? i have a similar issue too