MongoDB Atlas whitelist (dynamic IP)
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 closedThis 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
- Open the MongoDB Atlas dashboard.
- Go to the Network Access / IP Access List section.
- Add the address below:
0.0.0.0/0- Save the changes.
Security Note
Adding 0.0.0.0/0 opens the network so any IP can reach your cluster — so security now rests entirely on the authentication layers. Since you can't pin the IP on Square Cloud, offset it with these concrete mitigations:
- Strong, unique password for the database user (Atlas already enforces SCRAM authentication).
- Always-on TLS/SSL — Atlas forces the encrypted connection by default; don't disable it.
- Least-privilege user: create a dedicated user for the app with access only to the database it needs (avoid the admin role).
- Credential rotation: rotate the password periodically and whenever you suspect a leak; never commit the connection string to Git.
That way, even with the network open, no one reaches the database without the correct credentials.
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: 07/02/2026
Thank you!
