Articles on: Database & Storage

MongoDB Atlas Whitelist on Square Cloud

MongoDB Atlas Whitelist on Square Cloud


Square Cloud uses dynamic IP allocation for its applications. This means your instance does not maintain a fixed IP between restarts, so MongoDB Atlas needs to allow connections more broadly.



1. The Dynamic IP Problem


When connecting a MongoDB Atlas database to your Square Cloud application, you might see this error:


MongoNetworkError: connection 0 to shard-xxx-xxx.mongodb.net:27017 closed


This issue occurs because Atlas does not recognize your application's source IP, since it changes with every restart.



2. Why Does This Happen?


MongoDB Atlas requires you to add trusted source IPs to the whitelist. Since Square Cloud does not provide a static IP, it is not possible to add a single fixed address to Atlas.



3. How to Fix It


Step-by-Step


  1. Open the MongoDB Atlas dashboard.
  2. Go to the Network Access / IP Access List section.
  3. Add the address below:


0.0.0.0/0


  1. Save the changes.


Security Note


Adding 0.0.0.0/0 allows connections from any IP to your Atlas cluster. Use this setting only when necessary and review MongoDB Atlas security rules to limit access by user and firewall whenever possible.



4. Testing the Connection


After whitelisting on Atlas, try connecting your application again. If the error persists, check:


  • Whether the database is active on Atlas.
  • Whether the connection string is correct.
  • Whether the application is using the right Atlas cluster.




5. What to Do If It Still Doesn't Work


  • Confirm the cluster name and MongoDB Atlas user.
  • Verify if the application is configured to connect to the correct port.
  • If you use a VPC or additional rules on Atlas, adjust them accordingly.

Updated on: 05/22/2026

Was this article helpful?

Share your feedback

Cancel

Thank you!