mongodb config_error ai_generated true

MongoServerSelectionError: no server matches read preference

ID: mongodb/read-preference-error

Also available as: JSON · Markdown
80%Fix Rate
84%Confidence
3Evidence
2023-01-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
7 active

Root Cause

No replica set member matches the read preference.

generic

Workarounds

  1. 88% success Set appropriate read preference with maxStalenessSeconds
  2. 90% success Ensure secondary members are healthy: rs.status()

Dead Ends

Common approaches that don't work:

  1. Always use primaryPreferred 68% fail

    Stale reads without awareness

  2. Use nearest without maxStalenessSeconds 72% fail

    Potentially very stale data