Serverselectionerror - cPanel

How to solve the serverselectionerror problem in cPanel Node version 18.16.1

/home2/noonserv/ling.noonserv.com/node_modules/mongoose/lib/connection.js:825
  const serverSelectionError = new ServerSelectionError();
                               ^

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: https://www.mongodb.com/docs/atlas/security-whitelist/
    at Connection.openUri (/home2/noonserv/ling.noonserv.com/node_modules/mongoose/lib/connection.js:825:32)
    at /home2/noonserv/ling.noonserv.com/node_modules/mongoose/lib/index.js:414:10
    at /home2/noonserv/ling.noonserv.com/node_modules/mongoose/lib/helpers/promiseOrCallback.js:41:5
    at new Promise (<anonymous>)
    at promiseOrCallback (/home2/noonserv/ling.noonserv.com/node_modules/mongoose/lib/helpers/promiseOrCallback.js:40:10)
    at Mongoose._promiseOrCallback (/home2/noonserv/ling.noonserv.com/node_modules/mongoose/lib/index.js:1290:10)
    at Mongoose.connect (/home2/noonserv/ling.noonserv.com/node_modules/mongoose/lib/index.js:413:20)
    at Object.execute (/home2/noonserv/ling.noonserv.com/SRC/App/Events/Database.js:9:24)
    at /home2/noonserv/ling.noonserv.com/SRC/App/Handler/Events.js:8:24
    at Array.forEach (<anonymous>) {
  reason: TopologyDescription {
    type: 'Unknown',
    servers: Map(1) {
      'cluster0.dxxeohi.mongodb.net:27017' => ServerDescription {
        address: 'cluster0.dxxeohi.mongodb.net:27017',
        type: 'Unknown',
        hosts: [],
        passives: [],
        arbiters: [],
        tags: {},
        minWireVersion: 0,
        maxWireVersion: 0,
        roundTripTime: -1,
        lastUpdateTime: 58646458,
        lastWriteDate: 0,
        error: MongoNetworkError: getaddrinfo ENOTFOUND cluster0.dxxeohi.mongodb.net
            at connectionFailureError (/home2/noonserv/ling.noonserv.com/node_modules/mongodb/lib/cmap/connect.js:387:20)
            at Socket.<anonymous> (/home2/noonserv/ling.noonserv.com/node_modules/mongodb/lib/cmap/connect.js:310:22)
            at Object.onceWrapper (node:events:628:26)
            at Socket.emit (node:events:513:28)
            at emitErrorNT (node:internal/streams/destroy:151:8)
            at emitErrorCloseNT (node:internal/streams/destroy:116:3)
            at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
          cause: Error: getaddrinfo ENOTFOUND cluster0.dxxeohi.mongodb.net
              at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:107:26) {
            errno: -3008,
            code: 'ENOTFOUND',
            syscall: 'getaddrinfo',
            hostname: 'cluster0.dxxeohi.mongodb.net'
          },
          [Symbol(errorLabels)]: Set(1) { 'ResetPool' }
        },
        topologyVersion: null,
        setName: null,
        setVersion: null,
        electionId: null,
        logicalSessionTimeoutMinutes: null,
        primary: null,
        me: null,
        '$clusterTime': null
      }
    },
    stale: false,
    compatible: true,
    heartbeatFrequencyMS: 10000,
    localThresholdMS: 15,
    setName: null,
    maxElectionId: null,
    maxSetVersion: null,
    commonWireVersion: 0,
    logicalSessionTimeoutMinutes: null
  },
  code: undefined
}

Node.js v18.16.1

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: https://www.mongodb.com/docs/atlas/security-whitelist/

Did you make sure you whitelisted your host’s IP address?

If you whitelisted the IP already and still see this erorr, the underlying problem here seems to be that the host machine can’t resolve the host address for any members of the cluster. One option to try (if you’re using cPanel) is to clear the DNS cache and try again.