0

I'm trying to connect my node js app to MongoDB using mongoose. It works well and it connects without any problem. but when I want to connect MongoDB when my VPN is enabled it throws this error:

net:27017' => [ServerDescription] }, stale: false, compatible: true, compatibilityError: null, logicalSessionTimeoutMinutes: null, heartbeatFrequencyMS: 10000, localThresholdMS: 15, commonWireVersion: null } }

I was using this connection String:

mongodb+srv://parham:@testcluster.na0z1.mongodb.net/users?retryWrites=true&w=majority

note: password is obscured

then I contacted MongoDB support and they gave me this connection String for an older node version:

mongodb://parham:@testcluster-shard-00-00.na0z1.mongodb.net:27017,testcluster-shard-00-01.na0z1.mongodb.net:27017,testcluster-shard-00-02.na0z1.mongodb.net:27017/users?ssl=true&replicaSet=atlas-57dilh-shard-0&authSource=admin&retryWrites=true&w=majority

I don't know why but it connected the first time I used it but it never connected again.

here is my connection function

and it's somehow related to the first answer on stack overflow.

stack overflow question

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.