mongodb
config_error
ai_generated
true
MongoServerSelectionError: no server matches read preference
ID: mongodb/read-preference-error
80%Fix Rate
84%Confidence
3Evidence
2023-01-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 7 | active | — | — | — |
Root Cause
No replica set member matches the read preference.
genericWorkarounds
-
88% success Set appropriate read preference with maxStalenessSeconds
-
90% success Ensure secondary members are healthy: rs.status()
Dead Ends
Common approaches that don't work:
-
Always use primaryPreferred
68% fail
Stale reads without awareness
-
Use nearest without maxStalenessSeconds
72% fail
Potentially very stale data