MongoDB Connection Timeouts after 2nd Attempt

Hey all!

This is my first time writing a post here, so I hope I marked it in the right category! I’ve been using MongoDB Atlas on a website I’m running through Heroku. On my site, I have a button that triggers a write command. For some reason, I’m able to insert one document when I first open the site, but if I refresh my page or just try to add another document my connection times out. The write command is very basic and I followed the official documentation/examples closely. The thing that keeps puzzling me is the fact that the code works for the first requests, but just stops working thereafter for a few minutes.

Any help would be highly appreciated!

Thank you so much,
Tanush