0
0
MongodbHow-ToBeginner · 3 min read

How to Whitelist IP in MongoDB Atlas: Step-by-Step Guide

To whitelist an IP address in MongoDB Atlas, go to the Network Access section in your Atlas project, then click Add IP Address. Enter the IP address you want to allow and save the changes to enable access from that IP.
📐

Syntax

In MongoDB Atlas, whitelisting an IP address means adding it to the list of allowed IPs that can connect to your database cluster. This is done through the Atlas web interface under Network Access.

The main parts are:

  • Add IP Address: Button to start adding a new IP.
  • IP Address: The specific IP or IP range you want to allow.
  • Description: Optional note to identify the IP.
  • Confirm: Confirm and apply the whitelist entry.
text
1. Log in to MongoDB Atlas.
2. Select your project.
3. Navigate to Network Access > IP Whitelist.
4. Click Add IP Address.
5. Enter the IP address or CIDR block.
6. Optionally add a description.
7. Click Confirm to save.
💻

Example

This example shows how to whitelist a single IP address 203.0.113.5 to allow it access to your MongoDB Atlas cluster.

text
1. Log in to your MongoDB Atlas account.
2. Select your project.
3. Go to <strong>Network Access</strong> in the left sidebar.
4. Click <strong>Add IP Address</strong>.
5. In the dialog, enter <code>203.0.113.5</code> in the IP address field.
6. Optionally add a description like "Office IP".
7. Click <strong>Confirm</strong> to save.

After a few moments, this IP will be able to connect to your cluster.
Output
IP address 203.0.113.5 added to whitelist successfully.
⚠️

Common Pitfalls

  • Using incorrect IP format: Make sure to enter a valid IPv4 or IPv6 address or CIDR range.
  • Forgetting to save: Always click Confirm to apply changes.
  • Not allowing your current IP: If your IP changes often, consider adding 0.0.0.0/0 temporarily but be aware this allows access from anywhere.
  • Delays in propagation: Changes may take a few minutes to take effect.
text
/* Wrong way: */
Add IP address as "192.168.1"  -- incomplete IP

/* Right way: */
Add IP address as "192.168.1.0/24"  -- valid CIDR range
📊

Quick Reference

StepActionNotes
1Log in to MongoDB AtlasUse your account credentials
2Select your projectChoose the project with your cluster
3Go to Network AccessFound in the left sidebar
4Click Add IP AddressStarts the whitelist entry
5Enter IP or CIDRExample: 203.0.113.5 or 192.168.1.0/24
6Add description (optional)Helps identify the IP later
7Click ConfirmSaves and applies the whitelist

Key Takeaways

Whitelist IPs in MongoDB Atlas via the Network Access section.
Always enter valid IP addresses or CIDR ranges and save changes.
Allow your current IP to avoid connection issues during development.
Changes may take a few minutes to become active.
Use descriptions to keep track of whitelisted IPs.