Skip to main content
Virtus Cloud uses dynamic IP allocation as an exclusive platform technology — every time your application restarts, it receives a new, unique IP address. This approach constantly shifts your application’s network footprint, making it significantly more resilient against targeted network attacks. However, it also means you cannot whitelist a single static IP in MongoDB Atlas. Instead, you need to allow connections from all IP addresses using the 0.0.0.0/0 CIDR range, which is the officially supported approach for cloud platforms with dynamic IPs.

When Does It Occur?

You’ll see the following error in your application logs when your code attempts to open a connection to your MongoDB Atlas cluster:
MongoNetworkError: connection 0 to shard-xxx-xxx.mongodb.net:27017 closed
This error appears at startup or the first time your application calls a database operation, and it will recur on every deployment or restart until you update your Atlas IP access list.

Why Does It Occur?

MongoDB Atlas enforces an IP access list on every cluster. By default, no IP addresses are allowed to connect — you must explicitly whitelist the IP your application connects from. Because Virtus Cloud assigns a fresh IP on every application restart, any specific IP you add to the Atlas whitelist will become invalid the next time your application restarts, causing the MongoNetworkError.

How to Fix It

You need to add 0.0.0.0/0 to your MongoDB Atlas IP access list. This CIDR notation represents all IPv4 addresses and tells Atlas to accept connections from any source — including Virtus Cloud’s dynamic IPs.
1

Log in to MongoDB Atlas

Open cloud.mongodb.com and sign in to your Atlas account.
2

Select your project and cluster

From the Atlas dashboard, select the project that contains the cluster your application connects to.
3

Open the Network Access settings

In the left-hand navigation menu, click Network Access under the Security section.
4

Add a new IP access list entry

Click the Add IP Address button (or + Add IP Address if entries already exist).
5

Enter 0.0.0.0/0 and confirm

In the Access List Entry field, type 0.0.0.0/0. Optionally add a comment such as Virtus Cloud - dynamic IP in the Comment field for future reference. Click Confirm to save the entry.You can also click the Allow Access from Anywhere button in the dialog — it populates the 0.0.0.0/0 value for you.
6

Wait for the change to propagate

Atlas applies IP access list changes within a few seconds. Once the entry shows as Active, your application can connect.
7

Restart your application

Restart your application from the Virtus Cloud dashboard. The MongoNetworkError should no longer appear and your database operations should complete successfully.
Allowing 0.0.0.0/0 means any IP address on the internet can attempt a connection to your MongoDB cluster. Your cluster is still protected by your database user credentials — make sure you use a strong, unique password for your Atlas database user and follow the principle of least privilege when assigning user roles.

Verifying the Connection

After updating your Atlas access list and restarting your application, open the Logs panel in the Virtus Cloud dashboard. A successful MongoDB connection typically looks like:
MongoDB connected successfully
# or, for Mongoose:
Mongoose connected to mongodb+srv://...
If the MongoNetworkError persists after whitelisting 0.0.0.0/0, check the following:
Ensure your MONGODB_URI or connection string is correct. It should start with mongodb+srv:// for Atlas clusters and include your username, password, and cluster hostname. Double-check for typos in the cluster hostname.
Open Database Access in Atlas and confirm the user your application authenticates as exists and has the correct password. If in doubt, reset the user’s password and update your application’s environment variable.
From the Atlas dashboard, confirm your cluster is in an Active state and not paused. Free-tier clusters on Atlas pause automatically after 60 days of inactivity.
If you continue to experience connection issues after following these steps, contact the Virtus Cloud support team.