> For the complete MongoDB documentation index, see www.mongodb.com/docs/llms.txt

<!--
Tab options on this page. Append to the .md URL to filter:
  ?tabs=<id,...>   select specific tabs (e.g. ?tabs=nodejs,shell)
  ?allTabs=true    include every tab
  (no param)       default: one tab per tabset

Available tabs:
  other tabs: standard, peering, private
-->

# Connect to an Atlas Cluster

**Note:**

This page applies to both Atlas Infinite and Atlas Core.

This page describes how to connect to your Atlas cluster using the Atlas CLI or the Atlas UI.

## Prerequisites

#### IP Access List

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.](https://www.mongodb.com/docs/atlas/security/ip-access-list.md#std-label-add-to-access-list)

#### Database User

To access a cluster, you must have a [database user](https://www.mongodb.com/docs/manual/core/security-users/) 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](https://www.mongodb.com/docs/atlas/security-add-mongodb-users.md#std-label-mongodb-users). Atlas creates a database user when you create your first cluster.

### Open Ports 27015 to 27017 to Access Atlas Databases

Make sure your application can reach your MongoDB Atlas environment. To add the inbound network access from your application environment to Atlas, do one of the following:

1. Add the public IP addresses to your IP access list

2. Use [VPC / VNet peering](https://www.mongodb.com/docs/atlas/security-vpc-peering.md#std-label-vpc-peering) to add private IP addresses.

3. Add [private endpoints.](https://www.mongodb.com/docs/atlas/security-configure-private-endpoints.md#std-label-private-endpoint)

**See also:**

[IP Access List](https://www.mongodb.com/docs/atlas/setup-cluster-security.md#std-label-security-ip-access-list)

If your firewall blocks outbound network connections, you must also open outbound access from your application environment to Atlas. You must configure your firewall to allow your applications to make outbound connections to ports 27015 to 27017 to TCP (Transmission Control Protocol) traffic on the hostnames or IP addresses of your cluster. This grants your applications access to databases stored on Atlas.

To obtain the current list of cluster IP addresses, use the [Return All IP Addresses for One Project endpoint](https://www.mongodb.com/docs/api/doc/atlas-admin-api-v2/operation/operation-getgroupipaddresses) of the Atlas Administration API.

```text
curl --header "Authorization: Bearer <access-token>" \
     --header "Accept: application/vnd.atlas.2025-03-12+json" \
     --request GET \
     "https://cloud.mongodb.com/api/atlas/v2/groups/{GROUP-ID}/ipAddresses"
```

**See also:**

[Add Project Access from a Project](https://www.mongodb.com/docs/atlas/configure-api-access.md#std-label-create-project-api-key)

**Note:**

By default, MongoDB Atlas clusters do not need to be able to initiate connections to your application environments. If you wish to enable Atlas clusters with [LDAP authentication and authorization](https://www.mongodb.com/docs/atlas/security-ldaps.md#std-label-ldaps-authentication-authorization), you must allow network access from Atlas clusters directly to your secure LDAP (Lightweight Directory Access Protocol). You can allow access to your LDAP (Lightweight Directory Access Protocol) by using public or private IPs as long as a public DNS (Domain Name System) hostname points to an IP that the Atlas clusters can access.

If you are not using [VPC / VNet peering](https://www.mongodb.com/docs/atlas/security-vpc-peering.md#std-label-vpc-peering) and plan to connect to Atlas using public IP addresses, see the following pages for additional information:

- [Can I specify my own VPC for my MongoDB Atlas project?](https://www.mongodb.com/docs/atlas/reference/faq/networking.md#std-label-faq-atlas-side-hostnames)

- [Do Atlas cluster's public IPs ever change?](https://www.mongodb.com/docs/atlas/reference/faq/networking.md#std-label-faq-public-ip-changes)

## 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](https://www.mongodb.com/docs/atlas/scale-cluster.md#std-label-modify-cluster) to modify its number of nodes or regions.

## Connect to Your Cloud Cluster

To get your deployment's connection string, you can use the Atlas CLI or Atlas UI:

You can use the Atlas CLI to get your deployment's standard connection string.

To return the SRV connection strings for your Atlas cluster using the Atlas CLI, run the following command:

```sh

atlas clusters connectionStrings describe <clusterName> [options]

```

To learn more about the command syntax and parameters, see the Atlas CLI documentation for [atlas clusters connectionStrings describe.](https://www.mongodb.com/docs/atlas/cli/current/command/atlas-clusters-connectionStrings-describe/)

For example, if the Atlas CLI returns the following connection string:

```text
mongodb+srv://mycluster.abcd1.mongodb.net
```

You can connect to your deployment using [`mongosh`](https://www.mongodb.com/docs/mongodb-shell.md#mongodb-binary-bin.mongosh) by including the connection string in the [`mongosh`](https://www.mongodb.com/docs/mongodb-shell.md#mongodb-binary-bin.mongosh) command:

```text
mongosh "mongodb+srv://mycluster.abcd1.mongodb.net/myFirstDatabase" --apiVersion 1 --username <username>
```

**Note:**

To successfully connect to Atlas, you must add your username and database name to the connection string. In some cases, such as when you're using [`mongosh`](https://www.mongodb.com/docs/mongodb-shell.md#mongodb-binary-bin.mongosh) from the terminal, Atlas prompts you to enter the password for the database user.

### Connect to a Local Deployment with the Atlas CLI

To connect to an Atlas deployment using the Atlas CLI, run the following command:

```sh

atlas deployments connect [deploymentName] [options]

```

To learn more about the command syntax and parameters, see the Atlas CLI documentation for [atlas deployments connect.](https://www.mongodb.com/docs/atlas/cli/current/command/atlas-deployments-connect/)

1. In Atlas, go to the Clusters page for your project.

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

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

   In the sidebar, click Clusters under the Database heading.

   The [Clusters](https://cloud.mongodb.com/go?l=https%3A%2F%2Fcloud.mongodb.com%2Fv2%2F%3Cproject%3E%23%2Fclusters) page displays.

2. Click Connect.

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

3. Choose how you want to limit connections to your cluster.

   ### Standard Connection

   Add a Connection IP Address

   **Important:**

   Skip this step if Atlas indicates in the Setup connection security step that you have already configured an IP access list entry in your cluster. To manage the IP access list, see [Add Entries to the Access List.](https://www.mongodb.com/docs/atlas/security/ip-access-list.md#std-label-access-list)

   Atlas allows standard client connections to the cluster from entries in the [project's IP access list](https://www.mongodb.com/docs/atlas/security/ip-access-list.md#std-label-access-list). The project IP access list differs from the [API access list](https://www.mongodb.com/docs/atlas/configure-api-access.md#std-label-enable-api-access-list), which restricts *API* access to specific IP or CIDR (Classless Inter-Domain Routing) addresses.

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

   - Click Add Your Current IP Address to allow access from your current IP address.

   - Click Add an IP Address to add a single IP address or a CIDR (Classless Inter-Domain Routing)-notated range of addresses.

   Provide an optional description for the newly added IP address or CIDR (Classless Inter-Domain Routing) range. Click Add IP Address to add the address to the IP access list.

4. Create a Database User.

   **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.](https://www.mongodb.com/docs/atlas/security-add-mongodb-users.md#std-label-mongodb-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](https://www.mongodb.com/docs/manual/reference/built-in-roles.md#std-label-atlas-user-privileges) role.

   Enter the new user's Username.

   Enter a Password for this new user or click Autogenerate Secure Password.

   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.

5. Click Choose a connection method.

## Connect to Your Cloud Cluster Using Other Methods

In order to connect to your cluster, you must get your deployment's [Connection Strings](https://www.mongodb.com/docs/manual/reference/connection-string.md#std-label-find-connection-string). Once you have the connection string, you can connect to your deployment by using the following connection methods:

- [Connect to a Cluster via Client Libraries](https://www.mongodb.com/docs/atlas/driver-connection.md#std-label-connect-via-driver)

- [Connect to a Cluster via Compass](https://www.mongodb.com/docs/atlas/compass-connection.md#std-label-atlas-connect-via-compass)

- [Connect to a Cluster via mongosh](https://www.mongodb.com/docs/atlas/mongo-shell-connection.md#std-label-connect-mongo-shell)

- [Connect to a Cluster via VS Code](https://www.mongodb.com/docs/atlas/mongodb-for-vscode.md#std-label-mongodb-for-vscode)

- [MongoDB SQL Interface](https://www.mongodb.com/docs/sql-interface/) (to query your cluster from BI (Business Intelligence) tools such as Tableau and Power BI)

**Note:**

To connect using [`mongodump`](https://www.mongodb.com/docs/database-tools/mongodump.md#mongodb-binary-bin.mongodump) or [`mongorestore`](https://www.mongodb.com/docs/database-tools/mongorestore.md#mongodb-binary-bin.mongorestore), use the [Command Line Tools](https://www.mongodb.com/docs/atlas/command-line-tools.md#std-label-command-line-tools) option in the Cluster sidebar. This creates an auto-generated template for connecting to your Atlas cluster with your preferred tool.

## Troubleshooting

If you are experiencing issues connecting to your cluster, see [Troubleshoot Connection Issues.](https://www.mongodb.com/docs/atlas/troubleshoot-connection.md#std-label-atlas-troubleshoot-connections)

## Learn More

- [Browse Data via the Atlas UI](https://www.mongodb.com/docs/atlas/atlas-ui.md#std-label-atlas-ui)

- [Test Primary Failover](https://www.mongodb.com/docs/atlas/tutorial/test-resilience/test-primary-failover.md#std-label-test-failover)

- [Manage Connections with AWS Lambda](https://www.mongodb.com/docs/atlas/manage-connections-aws-lambda.md#std-label-atlas-lambda-connections)

- [Connection Limits and Cluster Tier](https://www.mongodb.com/docs/atlas/reference/atlas-limits.md#std-label-connection-limits)
