I am getting issue from API response.. Buffer time out error when deploy on cpanel but locally it works fine. I have also added the IP address in mongoDB network access but still getting issue

This is my error log file of cpanel:

MongoDb connection issue: 
text/x-log stderr.log ( ASCII text )
connection error:  MongoServerSelectionError: connect ECONNREFUSED 15.207.62.143:27017
    at Timeout._onTimeout (/home3/menuista/nodevenv/menuistan.info/20/lib/node_modules/mongodb/lib/sdam/topology.js:278:38)
    at listOnTimeout (node:internal/timers:573:17)
    at process.processTimers (node:internal/timers:514:7) {
  reason: TopologyDescription {
    type: 'ReplicaSetNoPrimary',
    servers: Map(3) {
      'ac-wuorahq-shard-00-00.1moqjmp.mongodb.net:27017' => [ServerDescription],
      'ac-wuorahq-shard-00-02.1moqjmp.mongodb.net:27017' => [ServerDescription],
      'ac-wuorahq-shard-00-01.1moqjmp.mongodb.net:27017' => [ServerDescription]
    },
    stale: false,
    compatible: true,
    heartbeatFrequencyMS: 10000,
    localThresholdMS: 15,
    setName: 'atlas-mccb1w-shard-0',
    maxElectionId: null,
    maxSetVersion: null,
    commonWireVersion: 0,
    logicalSessionTimeoutMinutes: null
  },
  code: undefined,
  [Symbol(errorLabels)]: Set(0) {}
}
connection error:  MongoServerSelectionError: connect ECONNREFUSED 13.232.206.107:27017
    at Timeout._onTimeout (/home3/menuista/nodevenv/menuistan.info/20/lib/node_modules/mongodb/lib/sdam/topology.js:278:38)
    at listOnTimeout (node:internal/timers:573:17)
    at process.processTimers (node:internal/timers:514:7) {
  reason: TopologyDescription {
    type: 'ReplicaSetNoPrimary',
    servers: Map(3) {
      'ac-wuorahq-shard-00-02.1moqjmp.mongodb.net:27017' => [ServerDescription],
      'ac-wuorahq-shard-00-00.1moqjmp.mongodb.net:27017' => [ServerDescription],
      'ac-wuorahq-shard-00-01.1moqjmp.mongodb.net:27017' => [ServerDescription]
    },
    stale: false,
    compatible: true,
    heartbeatFrequencyMS: 10000,
    localThresholdMS: 15,
    setName: 'atlas-mccb1w-shard-0',
    maxElectionId: null,
    maxSetVersion: null,
    commonWireVersion: 0,
    logicalSessionTimeoutMinutes: null
  },
  code: undefined,
  [Symbol(errorLabels)]: Set(0) {}
}
connection error:  MongoServerSelectionError: connect ECONNREFUSED 13.234.246.168:27017
    at Timeout._onTimeout (/home3/menuista/nodevenv/menuistan.info/20/lib/node_modules/mongodb/lib/sdam/topology.js:278:38)
    at listOnTimeout (node:internal/timers:573:17)
    at process.processTimers (node:internal/timers:514:7) {
  reason: TopologyDescription {
    type: 'ReplicaSetNoPrimary',
    servers: Map(3) {
      'ac-wuorahq-shard-00-01.1moqjmp.mongodb.net:27017' => [ServerDescription],
      'ac-wuorahq-shard-00-00.1moqjmp.mongodb.net:27017' => [ServerDescription],
      'ac-wuorahq-shard-00-02.1moqjmp.mongodb.net:27017' => [ServerDescription]
    },
    stale: false,
    compatible: true,
    heartbeatFrequencyMS: 10000,
    localThresholdMS: 15,
    setName: 'atlas-mccb1w-shard-0',
    maxElectionId: null,
    maxSetVersion: null,
    commonWireVersion: 0,
    logicalSessionTimeoutMinutes: null
  },
  code: undefined,
  [Symbol(errorLabels)]: Set(0) {}
}
connection error:  MongoServerSelectionError: connect ECONNREFUSED 13.234.246.168:27017
    at Timeout._onTimeout (/home3/menuista/nodevenv/menuistan.info/20/lib/node_modules/mongodb/lib/sdam/topology.js:278:38)
    at listOnTimeout (node:internal/timers:573:17)
    at process.processTimers (node:internal/timers:514:7) {
  reason: TopologyDescription {
    type: 'ReplicaSetNoPrimary',
    servers: Map(3) {
      'ac-wuorahq-shard-00-01.1moqjmp.mongodb.net:27017' => [ServerDescription],
      'ac-wuorahq-shard-00-02.1moqjmp.mongodb.net:27017' => [ServerDescription],
      'ac-wuorahq-shard-00-00.1moqjmp.mongodb.net:27017' => [ServerDescription]
    },
    stale: false,
    compatible: true,
    heartbeatFrequencyMS: 10000,
    localThresholdMS: 15,
    setName: 'atlas-mccb1w-shard-0',
    maxElectionId: null,
    maxSetVersion: null,
    commonWireVersion: 0,
    logicalSessionTimeoutMinutes: null
  },
  code: undefined,
  [Symbol(errorLabels)]: Set(0) {}
}

Hi there!

Since there wasn’t an error message, I ran this by our documentation bot. Here’s the response I got :slight_smile:

Let me know if it helps


Based on the error message you provided, it seems like you are experiencing a MongoDB connection timeout issue. This error occurs when the connection to the MongoDB server takes longer than the specified timeout value.

To troubleshoot this issue, you can try the following steps:

  1. Check the connection string: Verify that the connection string used in your API is correct and includes the correct hostname and port number for your MongoDB server.
  2. Check firewall settings: Ensure that the firewall on your cPanel server allows outgoing connections to the MongoDB server on the specified port (default is 27017). If necessary, open the port in the firewall settings.
  3. Check network access settings: Make sure that the IP address of your cPanel server is added to the MongoDB Atlas network access list. This allows your cPanel server to connect to the MongoDB server.
  4. Check server availability: Ensure that the MongoDB server is running and accessible. You can try connecting to the MongoDB server from your cPanel server using the MongoDB shell or a MongoDB client to verify its availability.

If you have followed these steps and are still experiencing the issue, it may be helpful to review the MongoDB documentation on connection troubleshooting for the specific driver and version you are using.

Related resources: