Hi,
I am having the same issue. My mongoose.connect
isn’t working, it just stopped working suddenly. I am quite new to MongoDB so I am afraid I don’t know how to change my DNS.
I am using port 5000.
app.listen(port, (req, res) => {
console.log(port);
})
mongoose.connect('mongodb+srv://<username>:<password>@cluster0.g1tk0kd.mongodb.net/?retryWrites=true&w=majority', {
useNewUrlParser: true,
useUnifiedTopology: true
}).then(()=>{
console.log('You are connected to mongoDB');
}).catch((error)=>{
console.log("mongoDb failed: ", error.message);
})
I’d appreciate any help, I have tried a different port. I also added another IP / another user. and the issue persists.
Kind regards,
Hey @Pedro_Lima1,
For troubleshooting this, you can attempt either of the following:
- Use another DNS server such as 8.8.8.8 (Google’s public DNS) to see if the issue is resolved
- Connect using the Standard Connection String format as noted in the following documentation.
- Attempt to connect from a different network connection
Please take note that it is recommended to use the DNS seed list connection string as the DNS can construct the list of the available servers allowing more flexibility of deployment and the ability to change the servers in rotation without reconfiguring clients.
However, in saying so, the above three methods should assist with initial connectivity troubleshooting related to the error provided.
Additionally, I would recommend reviewing the Troubleshoot Connection Issues documentation and verifying some configurations, such as adding the client’s IP (or IP ranges) to the Network Access List. You may also find the following blog post regarding tips for atlas connectivity useful.
If you’re still encountering further issues whilst connecting after attempting the above methods, please provide any error messages received.
Regards,
Kushagra