Question

Adjust TCP Timeout for MongoDB: Atlas

I’m currently running an application on DigitalOcean App Platform, but my database is hosted on MongoDB Atlas. Recently, I’ve encountered issues with TCP timeouts, particularly when I leave connections idle for a while. To address this, MongoDB [recommended](Timeout on insert Mongo Atlas with Azure Serverless backend - MongoDB Atlas - MongoDB Developer Community Forums) configuring the TCP timeout setting to 120 seconds, which I think isn’t possible in App Platform.

What are available options for me?

  • Should I move to Digital Ocean MongoDb?
  • Should deploy on a droplet, so that I can set the tcp timeout?

Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
October 21, 2024
Accepted Answer

Hey Jamal! 👋

I don’t think that with the App Platform you direct control over low-level networking configurations like TCP timeouts.

Is it possible for you to try adjusting other connection settings within your MongoDB Atlas cluster? For example, tweaking the connection pool settings (like maxIdleTimeMS) might help mitigate idle connection issues.

Another option here could be to consider moving to a DigitalOcean Managed MongoDB cluster instead, that might give a better networking latency as the database will be hosted within DigitalOcean’s infrastructure.

If none of those two options work for you, a workaround will be to move your application to a Droplet will give you full control over the system, including the ability to configure TCP timeouts directly. You can customize the server fully as you will have root access and you can make that suggested change from the MongoDB forum to meet your specific needs, but keep in mind this requires more management than a fully managed service like App Platform.

- Bobby

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.