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:


note: password is obscured

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


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.