Navigation

Connect via Compass

The Connect dialog for a cluster provides the details to connect to a cluster using Compass.

Prerequisites

TLS

Use MongoDB Compass 1.5 or later to connect to Atlas clusters. These versions support the required SNI TLS extension.

MongoDB Compass

To complete this procedure you must have MongoDB Compass installed. To install MongoDB Compass, do one of the following:

  • Follow the Installation Procedure in the MongoDB Compass documentation.
  • Download and install the latest version of MongoDB Compass using the download links provided in the Atlas Connect dialog. To access these links, click Connect for the cluster you wish to connect to, then click Connect with MongoDB |compass|.

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.

Connect to Your Cluster

Use the following procedure to connect MongoDB Compass 1.8 or later versions to your Atlas cluster.

1

Open the Connect dialog.

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

2

Choose your Connection Security.

Choose Connection Type from the set of available buttons.

Options Display if Feature Enabled

Atlas displays the connection type options after you enable Private IP for Peering, Private Endpoint, or both. If you haven’t enabled either feature, no buttons display and Connection Type defaults to Standard.

Use this connection type for whitelisted public IP addresses.

Use this connection type if you enabled peering:

  • For GCP or Azure and are connecting with Compass from a peered network, or
  • For AWS and are connecting with Compass from a peered network which uses a custom DNS service.

If neither of these apply, whitelist your IP address and use the Standard Connection string. If you are connecting directly to Atlas from an office or home network, this might be the preferred option.

Note

You can’t select this option unless one of your peers peers is marked as AVAILABLE. Navigate to Network Access to check the status of your peers.

Use the connection string for the appropriate interface endpoint if you are connecting with Compass over a Private Endpoint connection either because Compass:

  • Runs inside your cloud provider network, or
  • Has transitive network access to your cloud provider network.

If neither of these apply, whitelist your IP address and use the Standard Connection string. If you are connecting directly to Atlas from an office or home network, this might be the preferred option.

Note

You can’t select this option unless your configured PrivateLink connection is ready to use. Navigate to Network Access to check the status of your AWS PrivateLink.

3

Choose how you want to limit connections to your cluster.

Whitelist a Connection IP Address

Important

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.

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

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 an IP Address to add a single IP address or a CIDR-notated range of addresses.

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

Whitelist a Connection IP Address

Important

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.

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

If the whitelist is empty, Atlas prompts you to add an IP address to the project’s whitelist. Click Add a Different IP Address to add a single IP address or a CIDR-notated range of addresses.

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

Choose PrivateLink

Select the PrivateLink in your AWS region from the Choose PrivateLink menu.

4

Create a MongoDB User.

Important

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.

To access the cluster, you need a MongoDB user with access to the desired database(s) on the cluster in your project. If your project has no MongoDB users, Atlas prompts you to create a new user with the Atlas Admin role.

  1. Enter the new user’s Username
  2. Enter a Password for this new user or click Autogenerate Secure Password.
  3. 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.

5

Connect with MongoDB Compass.

  1. In the Choose a connection method step, select Connect with MongoDB Compass.

  2. If you have Compass installed, click I have Compass in the ensuing dialog page.

    If you do not have Compass installed, refer to the Prerequisites section.

  3. Choose your version of MongoDB Compass in the dropdown. To check your version of Compass, click About MongoDB Compass in the application.

  4. Copy the connection string presented in the Atlas Connect dialog.

  5. Open MongoDB Compass.

  6. Compass automatically detects the URI connection string in the system clipboard and asks for permission to auto-fill the connection form with the appropriate information. Click Yes.

  7. Fill in the Password field with the password for the user from the connection string. For security purposes, the connection string does not include the password.

    To connect with a different MongoDB user, update the Username and Password fields with the username and password of a different MongoDB user.

  8. (Optional) To save this connection for future use, fill in the Favorite Name field with a name for this connection. Click Create Favorite.

    Saved favorite connections appear in the left pane of the Compass Connect window under Favorites.

  9. Click Connect.

See also

For more detailed instructions on connecting to a database using MongoDB Compass, refer to the Connect Page in the Compass documentation.

For MongoDB Compass 1.7 or earlier versions, you can manually create a new connection in Compass.

To set up a New Connection from MongoDB Compass to your Atlas cluster, enter the following information in MongoDB Compass and click Connect:

Field Name Description
Hostname

Hostname of primary for a replica set or the hostname for the mongos for a sharded cluster.

To locate the hostname of the replica set primary in the Atlas UI:

  1. Click Clusters.
  2. Click the cluster to which you want to connect.
  3. Click on the replica set member marked as PRIMARY.
  4. Copy the hostname of the replica set.

To locate the hostname for a sharded cluster in the Atlas UI:

  1. Click Connect for the cluster.
  2. Click Connect Your Application.
  3. Extract the mongos hostname from the URI connection string.

Make note of the port number of the primary or mongos. Use that port to fill in the Port field in MongoDB Compass.

Port Port of the primary for a replica set or the port of the mongos for a sharded cluster.
Authentication Select Username / Password.
Username MongoDB user. The Atlas connection string displays the MongoDB administration user set up for the cluster. You can connect with a different MongoDB user.
Password Password associated with the specified MongoDB user.
Authentication Database Specify "admin".
Replica Set Name

Name of the Atlas cluster’s replica set.

To retrieve the replica set name:

  1. Click the Connect button for the cluster.
  2. Select Connect Your Application.
  3. Extract the replica set name from the URI connection string’s replicaSet value.
Read Preference Specify how MongoDB Compass directs read operations. Options are Primary, Primary Preferred, Secondary, Secondary Preferred, and Nearest. See /core/read-preference.
SSL Select "Use System CA / Atlas Deployment"
SSH Tunnel Select "Off"
Favorite Name Enter a name for the connection if you want to save it as a favorite.

Troubleshooting

If you are experiencing issues connecting to your cluster, see Troubleshoot Connection Issues.