Quantcast
Channel: Active questions tagged mongodb-atlas - Stack Overflow
Viewing all articles
Browse latest Browse all 271

Problem with deploying my app with Render, MongoDB doesn't recognize and whitelist my IP and doesn't allow me to connect to the cluster

$
0
0

MongooseServerSelectionError Could not connect to any servers in your MongoDB Atlas cluster. One common reason is that you're trying to access the database from an IP that isn't whitelisted. Make sure your current IP address is on your Atlas cluster's IP whitelist: https://www.mongodb.com/docs/atlas/security-whitelist/

Hello everyone, this is the error that I get, when trying to deploy my app with Render. The app is built and deployed successful, but crashes with this error nonetheless.


I searched and read articles and previous questions asked in StackOverflow, but many suggest that I need to allow access for every IP address ( 0.0.0.0/0 ) to be able to connect to my mongo cluster. Although this solves my problem and the app is deployed successfully after that, I suppose this isn't good for the security of my app and particularly my database.


This is how I connect to the database in my code ( I don't know if it is needed, but I will provide it in either way):


const DB = process.env.DATABASE.replace('<PASSWORD>',  process.env.DATABASE_PASSWORD);(async () => {  await mongoose.connect(DB, { });})();const port = process.env.PORT ?? 3000;const server = app.listen(port, () => {  console.log('Go go go');});

I wanna ask:

  1. Is it actually required, that my IP is the only one connected to thedatabase, I mean, if others want to create something on theapplication, that needs to be stored in my database ( for example newpost, if my app is forum ), isn't it necessary that they (particularlytheir IP) also has to be connected to the database ( I suppose theyneed to send the post to the db ) and if so, is allowing access forevery IP address the way to solve it?

  2. And also, can you suggest other solutions, that work, but are notthreatening the security of my app?



Viewing all articles
Browse latest Browse all 271

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>