Debugging connection process

Hi. I am using Mongoose to connect to a MongoDB Atlas instance, but the initial connection takes about 30 seconds. I didn’t have this issue before; it used to take my server a couple of seconds to make the connection. I tried to log the process with the MongoDB driver logger, but it seems like logging is not available from version 4 upwards. How can I access the logs where steps regarding the initial database connection are recorded?
I’m running my Node app on an Ubuntu 20 server

Hi :wave: @Pooya_he,

Welcome to the MongoDB Community forums :sparkles:

  • Could you share more details, such as the version of Mongoose you are using, the deployment details (whether it’s MongoDB Atlas or locally deployed), and the MongoDB version?

  • Have you changed anything recently in your codebase that could affect the connection latency?

However, you can enable the logging in mongoose using the debug option. Please refer to the link to learn more: Mongoose v8.4.4: FAQ

In case you are looking to use MongoDB Native Nodejs driver and enable the logging, please refer to the driver documentation here.

I hope it helps.

Best,
Kushagra

Thank you for answering

I am using mongoose 8.4.3 to connect to a MongoDB Atlas instance.

Enabling the debug option in the mongoose only shows info for CRUD commands being executed and show no info about DB connection.

Also regarding latest documentation logger is replaced by monitoring which is again useful for debugging CRUD commands.

I guess I have to resort to packet capture for the DB connection debugging