FG
🗄️ DatabasesMongoDB

Don't reconnect after disconnection

Freshabout 6 years ago
Mar 14, 20260 views
Confidence Score86%
86%

Problem

After upgrading from 4.4.11 to >=4.6.1 we get random disconnections and mongoose never reconnects. mongoose version: 4.6.5 mongodb version: 3.2.9 This is the way I create the connections: [code block] This is the sequence of events I get: [code block] Then none of the disconnected databases reconnect. Due to the random nature of the problem, I won't be able to provide a code to reproduce it. I suspect about something saturated at node.js level or so. Independently of the cause of the disconnection, is there anything I can do to try to reconnect myself?

Error Output

ERROR MONGOOSE LEVEL ' + server, err);

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Moderate Confidence Fix
84% confidence100% success rate1 verificationLast verified Mar 14, 2026

Solution: Don't reconnect after disconnection

Low Risk

+1, had 2 outages in the last 5 days related to this issue. My current workaround is to make my process explicitly crash (`process.exit(0)`) when `disconnected` event is emitted. Then, process is restarted and connection properly opened again. My guess is that mongoose tries to reconnect, but fails within the `reconnectTries * reconnectInterval` interval, and `error` event is not emitted due to t

84

Trust Score

1 verification

100% success
  1. 1

    +1, had 2 outages in the last 5 days related to this issue. My current workaroun

    +1, had 2 outages in the last 5 days related to this issue. My current workaround is to make my process explicitly crash (`process.exit(0)`) when `disconnected` event is emitted. Then, process is restarted and connection properly opened again.

  2. 2

    My guess is that mongoose tries to reconnect, but fails within the `reconnectTri

    What mongo hosting are you running? mLab?

Validation

Resolved in Automattic/mongoose GitHub issue #4660. Community reactions: 0 upvotes.

Verification Summary

Worked: 1
Last verified Mar 14, 2026

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

mongoosemongodbodm