Question
MongoDb database connection time out error
When i tried to get connected to mongodb i got a timeout error,
i have added firewall rules for remote access.
what I did :
- Incoming rules => added new rule => custom TCP | 27017 | All IPv4 All IPv6
the mongo server is running and the user has rules in a specific database.
note : I run it successfully on AWS before with the same steps .
I m sure the error that I got is about the remote access IP .
error :
MongooseServerSelectionError: connection timed out
at NativeConnection.Connection.openUri (C:\scrap-source\node_modules\mongoose\lib\connection.js:845:32)
at C:\scrap-source\node_modules\mongoose\lib\index.js:345:10
at promiseOrCallback (C:\scrap-source\node_modules\mongoose\lib\helpers\promiseOrCallback.js:9:12)
at Mongoose._promiseOrCallback (C:\scrap-source\node_modules\mongoose\lib\index.js:1135:10)
at Mongoose.connect (C:\scrap-source\node_modules\mongoose\lib\index.js:344:20)
at Object.<anonymous> (C:\scrap-source\server.js:8:5)
at Module._compile (node:internal/modules/cjs/loader:1108:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1137:10)
at Module.load (node:internal/modules/cjs/loader:973:32)
at Function.Module._load (node:internal/modules/cjs/loader:813:14)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)
at node:internal/main/run_main_module:17:47 {
reason: TopologyDescription {
type: 'Single',
setName: null,
maxSetVersion: null,
maxElectionId: null,
servers: Map(1) { 'My_private_IP':27017' => [ServerDescription] },
stale: false,
compatible: true,
compatibilityError: null,
logicalSessionTimeoutMinutes: null,
heartbeatFrequencyMS: 10000,
localThresholdMS: 15,
commonWireVersion: null
}
}
thanks.
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
×