Mongo atlas connection error

Hello community,
I am working on the ExpressJS web services project. We have created a free cluster in MongoDB Atlas and I am trying to connect to the DB using the connection string provided by the website itself (mongodb+srv://:@cluster0.0jqio.mongodb.net/?retryWrites=true&w=majority). I have whitelisted my own IP and made it accessible from anywhere as well.
Sometimes it is connected but sometimes it gives me error “Could not connect to any servers in your MongoDB Atlas cluster. One common reason is that you’re trying to access the 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/”.
But I do not think that is the issue as I was able to connect to the cluster using my MongoDB Compass, Mongosh and VS Code MongoDB extension.

Hello @Tien_Pham1 … If you can consistently, every time, connect via Compass, Mongosh, and VSCode and only experience failures in your application coded using ExpressJS, then there is either a bug in your application code or in ExpressJS itself.