Navigation

Connect to a Cluster

Prerequisites

Whitelist
To access a cluster, you must connect from an IP address on the Atlas project’s IP whitelist. If you need to add an IP address to the whitelist, you can do so in the Connect dialog. You can also add the IP address from the Security tab.
MongoDB User

To access a cluster, you must create a MongoDB User with access to the desired database(s) on your Atlas cluster. MongoDB users are separate from Atlas users. MongoDB users have access to MongoDB databases, while Atlas users have access to the Atlas application itself.

You can create a MongoDB user to access to your Atlas cluster in the Connect dialog. You can also add the MongoDB user from the Clusters view.

Open Ports 27015 to 27017 to Access Atlas Databases

You must ensure that your application can reach your MongoDB Atlas environment. To ensure connectivity with Atlas, you must whitelist the inbound network access from your application environment to MongoDB Atlas by either whitelisting public IP addresses, or using VPC / VNet peering to whitelist private IP addresses. To learn more about IP whitelisting, see Whitelist.

If your firewall blocks outbound network connections, you must also open outbound access from your application environment to MongoDB Atlas. You must configure your firewall to allow your applications to make outbound connections to ports 27015 to 27017 to TCP and UDP traffic on Atlas hosts. This grants your applications access to databases stored on Atlas.

Note

By default, MongoDB Atlas clusters do not need to be able to initiate connections to your application environments. However, if you wish to enable Atlas clusters with LDAP authentication and authorization, you must allow network access from Atlas clusters directly to your secure LDAP. You can allow access to your LDAP by using public or private IPs as long as a public DNS hostname points to an IP that the Atlas clusters can access.

If you are not using VPC / VNet peering and plan to connect to MongoDB Atlas using public IP addresses, see the following pages for additional information:

Use the Connect dialog to Connect to Your Cluster

1

Open the Connect dialog.

In the Clusters view, click the Connect button for the cluster to which you want to connect.

2

Whitelist your connection IP address.

Atlas only allows client connections to the cluster from entries in the project’s whitelist. The project whitelist is distinct from the API whitelist, which restricts API access to specific IP or CIDR addresses.

Note

You can skip this step if Atlas indicates in the Setup Connection Security step that you have already configured a whitelist entry in your cluster. To manage the IP whitelist, see Add Entries to the Whitelist.

If the whitelist is empty, Atlas prompts you to add an IP address to the project’s whitelist. You can either:

  • Click Add Your Current IP Address to whitelist your current IP address.

  • Click Add a Different IP Address to add a single IP address or a CIDR-notated range of addresses.

    For Atlas clusters deployed on Amazon Web Services (AWS) and using VPC Peering, you can add a Security Group associated with the peer VPC.

You can provide an optional description for the newly added IP address or CIDR range. Click Add IP Address to add the address to the whitelist.

3

Create a MongoDB User.

To access the cluster, you must create a MongoDB user with access to the desired database(s) on the cluster.

Note

You can skip this step if Atlas indicates in the Setup Connection Security step that you have at least one MongoDB user configured in your project. To manage existing MongoDB users, see Add MongoDB Users.

If the project has no MongoDB users, Atlas prompts you to create a new user with the Atlas Admin privilege. Enter the new user’s Username and Password and click Create MongoDB User to save the user. Use this user to connect to your cluster in the following step.

Once you have whitelisted an IP address and added a MongoDB user, click Choose Your Connection Method.

4

Select your preferred connection method.

In the Choose a connection method step, Atlas provides instructions for each listed connection method. Click your preferred connection method and follow the instructions given.

For connecting via a command line tool such as mongodump or mongorestore, use the Command Line Tools tab for an auto-generated template for connecting to your Atlas cluster with your preferred tool.

Considerations

Atlas does not guarantee that host names remain consistent with respect to node types during topology changes.

Example

If you have a cluster named foo123 containing an analytics node foo123-shard-00-03-a1b2c.mongodb.net:27017, Atlas does not guarantee that specific host name will continue to refer to an analytics node after a topology change, such as scaling a cluster to modify its number of nodes or regions.