When i tried to get connected to mongodb i got a timeout error, i have added firewall rules for remote access. what I did :
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.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
The first thing I always double-check is to see if the service is listening on my public interface (eg, eth0):
sudo netstat -tnlp
That will list on all running services and the interface / port they are listening on. If your mongodb instance is not listening on the IP you’re trying to connect to or 0.0.0.0 (all interfaces), you won’t be to able to remotely connect.
If mongodb is listening on the correct interface, the next step would be to check the mongodb logs for any additional information about your connection attempts.
Hope these hints help, please let us know if there’s any other questions or feedback on this advice - thanks and good luck!
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.