P
Prisma2mo ago
u007

mongodb connection randomly unable to connect

https://github.com/prisma/prisma/discussions/11929#discussioncomment-9600119 Error: MongoDB error Server selection timeout: No available servers. Topology: { Type: ReplicaSetNoPrimary, Servers: this happen randomly after 2 to 3days of running on production
GitHub
Error: MongoDB error Server selection timeout: No available servers...
Hi, I tried to run mongo on Docker, but when I type prisma db push I get this error, can you help? Connectiong String: mongodb://username:password@localhost:27017/akillisatici?authSource=admin&...
2 Replies
u007
u0072mo ago
[Nest] 7 - 05/28/2024, 10:34:58 AM ERROR [ExceptionHandler] Could not connect to any servers in your MongoDB Atlas cluster. One common reason is that you're trying to access the database from an IP that isn't whitelisted. Make sure your current IP address is on your Atlas cluster's IP whitelist: https://www.mongodb.com/docs/atlas/security-whitelist/
u007
u0072mo ago
ive added 0.0.0.0 to the allowed ip again happening: again happening: return this.prisma.user.findUnique( vhnest_1 | Raw query failed. Code: unknown. Message: `Server selection timeout: None of the available servers suitable for criteria ReadPreference(Primary). Topology: { Type: ReplicaSetNoPrimary, Servers: [ { Address: :27017, Type: RsSecondary, Average RTT: 3.281146ms, Last Update Time: DateTime(OffsetDateTime { local_datetime: PrimitiveDateTime { date: Date { year: 2024, ordinal: 152 }, time: Time { hour: 5, minute: 58, second: 44, nanosecond: 237000000 } }, offset: UtcOffset { hours: 0, minutes: 0, seconds: 0 } }), Max Wire Version: 21, Min Wire Version: 0, Replica Set Name: atlas-lxzpd2-shard-0, Replica Set Version: 44, Tags: {"nodeType": "ELECTABLE", "diskState": "READY", "workloadType": "OPERATIONAL", "provider": "AWS", "region": "AP_SOUTHEAST_1", "availabilityZone": "apse1-az1"} }, { Address: :27017, Type: RsSecondary, Average RTT: 4.461106ms, Last Update Time: DateTime(OffsetDateTime { local_datetime: PrimitiveDateTime { date: Date { year: 2024, ordinal: 152 }, time: Time { hour: 5, minute: 58, second: 44, nanosecond: 346000000 } }, offset: UtcOffset { hours: 0, minutes: 0, seconds: 0 } }), Max Wire Version: 21, Min Wire Version: 0, Replica Set Name: ***-0, Replica Set Version: 44, Tags: {"availabilityZone": "apse1-az2", "workloadType": "OPERATIONAL", "diskState": "READY", "nodeType": "ELECTABLE", "provider": "AWS", "region": "AP_SOUTHEAST_1"} }... i suspect this has todo with atlas connection limit im not sure, but ive implemented dnsmasq to fallback dns issue incase if it fails