Mongo DB error making AWS Elastic Beanstalk Server Down

web:

/var/app/current/node_modules/mongoose/node_modules/mongodb/lib/cmap/connection.js:121
 this.cleanup(true, new error_1.MongoNetworkError(message));
^
MongoNetworkError: connection 188 to 35.173.172.50:27017 closed
at Connection.onClose (/var/app/current/node_modules/mongoose/node_modules/mongodb/src/cmap/connection.ts:320:24)
at TLSSocket.<anonymous> (/var/app/current/node_modules/mongoose/node_modules/mongodb/src/cmap/connection.ts:245:42)
ip-172-31-32-37 web: at TLSSocket.emit (node:events:513:28)
ip-172-31-32-37 web: at TLSSocket.emit (node:domain:489:12)
ip-172-31-32-37 web: at node:net:301:12
at TCP.done (node:_tls_wrap:588:7) {
[Symbol(errorLabels)]: Set(1) { 'RetryableWriteError' }
}
#033[31m[nodemon] app crashed - waiting for file changes before starting...#033[39m

The above error close node app on AWS elastic beanstalk I am using mongoose and mongo db serverless instance

Hey @Junaid_Ranjha,

Welcome to the MongoDB Community forums.

Looking at the error stack trace, it appears that the application is encountering difficulties establishing a connection to your MongoDB Serverless Instance. This could be due to likely issues with IP whitelisting or a VPC peering problem.

To further understand, could you please provide additional information? Specifically, details on whether this issue is intermittent or persistent, any recent changes made to your network settings, and the workflow you followed. Additionally, please provide version details of Mongoose and MongoDB.

Meanwhile, you can refer to the following blog: Application Modernization with AWS Elastic Beanstalk and MongoDB Atlas | AWS Partner Network (APN) Blog to read step-by-step instructions and the workflow.

Best regards,
Kushagra

It doesn’t seem like IP problem because it does connect and works fine but at times it gives this error. I have allowed all IP using 0.0.0.0/0. The mongoose version is 7.4 . Waiting for your response any help is appreciated