Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9129109
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:40:16+00:00 2026-06-17T07:40:16+00:00

When my MongoDB connection is idle for a few minutes, the next request ends

  • 0

When my MongoDB connection is idle for a few minutes, the next request ends in error. From the mongo command line client, it looks like this:

> db.users.find()
Sat Jan 12 23:42:35 Socket recv() errno:54 Connection reset by peer 107.22.25.25:47207
Sat Jan 12 23:42:35 SocketException: remote: 107.22.25.25:47207 error: 9001 socket exception [1] server [107.22.25.25:47207] 
Sat Jan 12 23:42:35 DBClientCursor::init call() failed
Sat Jan 12 23:42:35 query failed : chowology.users {} to: ds047207.mongolab.com:47207
Error: error doing query: failed
Sat Jan 12 23:42:35 trying reconnect to ds047207.mongolab.com:47207
Sat Jan 12 23:42:35 reconnect ds047207.mongolab.com:47207 ok

I see the problem against sandbox instances of MongoHQ and MongoLab.

The next request goes through fine, because of the reconnect. This is a problem in my web app, because after a few minutes of inactivity, this error will come up during a web request. There are two things that surprise me:

  1. That MongoDB connections are destroyed so regularly and frequently, and
  2. That the driver simply raises an exception as opposed to automatically retrying after reconnecting (I’m using connect-mongo which uses mongoose which, in turn, uses node-mongodb-native).

Is this everyone else’s experience? How is this supposed to be handled? I’d be surprised if app developers wrap their database operations in some retry-exception-handling nonsense.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T07:40:17+00:00Added an answer on June 17, 2026 at 7:40 am

    You want to look at the docs for the Server object

    http://mongodb.github.com/node-mongodb-native/api-generated/server.html#server

    Especially the socketOptions where you can set keepAlive and the connection timeouts. By default keepalive is off and timeout is 0 or never which means the os default socket timeout is in effect (varies from os to os). Keep alive will send a packet once in awhile down the tcp socket connection to keep it alive. Sometimes firewalls are badly configured and don’t send an end packet when they close a connection leaving the connection dead and in limbo which is what the monoglabs people are talking about (more often than not to be honest they are horribly configured).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

def process_health_case(request): about = request.POST['about'] details = request.POST['narrative_text'] image=request.FILES['image_scan'] connection = Connection('mongodb://sbose78:PASSWORD@staff.mongohq.com:10068/BOSE') if images:
Hi I am having trouble keeping connection with my MongoDB and it ends up
I have mongodb and NodeJs. The connection is done via mongoosejs . What is
I've got a MongoDB collection that looks something like this: [ { title: Entry
I'm trying to insert a large amount of text into a mongodb collection from
How can you drop a numeric collection from MongoDB? PRIMARY> db.123456789011.remove({}); Tue Mar 20
I have been having a problem where after my mongodb connection to mongohq via
I am using the latest spring-data-mongodb (1.1.0.M2) and the latest Mongo Driver (2.9.0-RC1). I
I am inserting documents into MongoDB from a map in a MapReduce job. A
I can't connect mongodb on server with debian and python 2.6.6 on this line:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.