For AI agents: a documentation index is available at https://www.mongodb.com/docs/llms.txt — markdown versions of all pages are available by appending .md to any URL path.
Docs Menu

Connect to a Cluster via Compass

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

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

To complete this procedure, do one of the following:

  • Install MongoDB Compass. See Compass Installation.

  • Upgrade to the latest version of MongoDB Compass by downloading MongoDB Compass from links in the Atlas Connect dialog box. To access these links, click Connect for the cluster you wish to connect to, then click Compass.

To access a cluster, you must connect from an IP address on the Atlas project's IP access list. If you need to add an IP address to the IP access list, you can do so in the Connect dialog box. You can also add the IP address from the Network Access tab.

To access a cluster, you must have a database user with access to the desired databases on your Atlas cluster. Database users are separate from Atlas users. Database users have access to MongoDB databases, while Atlas users have access to the Atlas application itself.

You can create a database user to access your Atlas cluster in the Connect dialog box. You can also add the database user from the Cluster view. Atlas creates a database user when you create your first cluster.

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

1
  1. If it's not already displayed, select the organization that contains your desired project from the Organizations menu in the navigation bar.

  2. If it's not already displayed, select your desired project from the Projects menu in the navigation bar.

  3. In the sidebar, click Clusters under the Database heading.

The Clusters page displays.

2

Click Connect for the cluster to which you want to connect.

3

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.

Under Choose Connection Type, select one of the following connection types:

4
5

IMPORTANT: Skip this step if Atlas indicates in the Setup connection security step that you have at least one database user configured in your project. To manage existing database users, see Configure Database Users.

To access the cluster, you need a MongoDB user with access to the desired database or databases 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 Database User to save the user.

Use this user to connect to your cluster in the following step.

Once you have added an IP address to your IP access list and added a database user, click Choose Your Connection Method.

6
  1. Click I have MongoDB Compass.

  2. Choose your version of MongoDB Compass in the dropdown. To check the version of MongoDB Compass that you have installed on your system, click About MongoDB Compass in the application.

  3. Copy the connection string presented in the Atlas Connect dialog box.

7

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. In Atlas, go to the Clusters page for your project.

    1. If it's not already displayed, select the organization that contains your desired project from the Organizations menu in the navigation bar.

    2. If it's not already displayed, select your desired project from the Projects menu in the navigation bar.

    3. In the sidebar, click Clusters under the Database heading.

      The Clusters page displays.

  2. Click the cluster to which you want to connect.

  3. Click 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 user interface:

  1. Click Connect for the cluster.

  2. Click Drivers.

  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.

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