> This page location: /docs.md > /docs/management.md > /docs/atlas/reference.md > /docs/atlas/faq.md

> 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: console, api
-->

# FAQ: Connection String Options

**Note:**

Some answers on this page apply to Atlas Core clusters only. To learn which features Atlas Infinite supports, see [Public Preview Availability.](https://www.mongodb.com/docs/atlas/infinite/atlas-infinite-landing.md#std-label-atlas-infinite-availability)

Atlas provides multiple connection strings. These strings allow you to connect to your clusters from both public and private contexts. Atlas always assigns clusters unique connections strings so that no two clusters share hostnames or connection strings across Atlas.

## How do I identify which connection string my application uses?

The structure of the connection string's URI (Uniform Resource Identifier) indicates the string's type. If you have created a peering connection or private endpoint, Atlas displays more than one of these options for your use.

## Why does my cluster have multiple connection strings?

To connect to Atlas, point your applications to a URI (Uniform Resource Identifier) to communicate with a cluster. Atlas creates clusters with more than one node or host. Each node has its own hostname that resolves to an IP address. The URI (Uniform Resource Identifier), known as a *connection string*, to which Atlas connects might have more than one hostname. Configure Atlas to accept connections to the cluster hosts from allowed IP addresses.

Always use the [Atlas-provided connection string](https://www.mongodb.com/docs/atlas/resilient-application.md#std-label-atlas-connection-string) and rely on [driver discovery](https://www.mongodb.com/docs/manual/reference/connection-string-formats.md#std-label-connections-dns-seedlist) when you build a well-architected application. Don't hard-code node hostnames. To learn more, see [Guidance for Atlas Network Security.](https://www.mongodb.com/docs/atlas/architecture/current/network-security.md#std-label-arch-center-network-security)

Atlas secures connections from public IP address through authentication and TLS (Transport Layer Security). If you want to connect to private IP addresses, you can use:

- [AWS and GCP VPC Peering](https://www.mongodb.com/docs/atlas/security-vpc-peering.md#std-label-vpc-peering)

- [Azure VNet Peering](https://www.mongodb.com/docs/atlas/security-vpc-peering.md#std-label-vpc-peering)

- [AWS PrivateLink and Azure Private Link](https://www.mongodb.com/docs/atlas/security-private-endpoint.md#std-label-private-endpoint-connection-strings)

These features all manage communication over internal IP addresses within secure networks.

Atlas provides more than one connection string when using secure networks. Each network offers a string that resolves to different IP addresses.

All clusters have a [standard connection string](https://www.mongodb.com/docs/atlas/reference/faq/connection-changes.md#std-label-connstring-standard). This resolves to the cluster's:

- Public IP addresses for Internet connections and

- VPC (Virtual Private Cloud) private IP addresses for AWS (Amazon Web Services) clusters when resolved from a peered VPC (Virtual Private Cloud).

Use this string for applications connecting over the Internet or connecting to peered clusters in AWS (Amazon Web Services).

Clusters with peered networks have a [Private IP for Peering connection string](https://www.mongodb.com/docs/atlas/reference/faq/connection-changes.md#std-label-connstring-private). This string resolves to IP addresses available to:

- Peered networks in Azure (Microsoft Azure) or Google Cloud

- AWS (Amazon Web Services) peered clusters with a custom DNS (Domain Name System) service.

Use this connection string with applications connecting:

- Within an Azure (Microsoft Azure) or Google Cloud peered network

- To AWS (Amazon Web Services) clusters when using AWS (Amazon Web Services) with custom DNS (Domain Name System) service.

AWS (Amazon Web Services) or Azure (Microsoft Azure) clusters in regions with [private endpoints](https://www.mongodb.com/docs/atlas/security-private-endpoint.md#std-label-private-endpoint-connection-strings) configured have one or more connection strings. Each string resolves to the private IP address of a network interface in your VPC (Virtual Private Cloud) or VNet that connects directly to a load balancer in the Atlas VPC (Virtual Private Cloud) or VNet. Use these connection strings with applications connecting with private endpoints.

## Can I use a single MongoDB SRV connection string for a multi-region cluster with private link?

Yes, you can use a single SRV (DNS Service Record) connection string for a multi-region cluster with Private Link in MongoDB Atlas. The SRV (DNS Service Record) connection string automatically resolves to the appropriate nodes across regions. However, ensure that your network setup allows for cross-region connectivity through private endpoints. For AWS (Amazon Web Services) and Azure (Microsoft Azure), this involves setting up VPC/VNet peering between regions. For Google Cloud, you need to configure global access for Private Service Connect.

To learn more, see the documentation for [private endpoints.](https://www.mongodb.com/docs/atlas/security-private-endpoint.md#std-label-private-endpoint-overview)

## What does this mean for Google Cloud or Azure (Microsoft Azure) clusters in peering-only mode?

Before 31 March 2020, you were required to enable peering-only mode to connect to databases on peer networked Azure (Microsoft Azure) or Google Cloud clusters. This mode:

- Affected global DNS (Domain Name System) resolution and

- Limited any database connections outside the peered network.

Multiple horizons lifts these restrictions and unlocks the following additional features:

- [Charts](https://www.mongodb.com/docs/charts/)

- [Live Migration](https://www.mongodb.com/docs/atlas/import.md#std-label-import-strategies)

To leverage multiple horizons, complete the following tasks:

- Update your application's existing connection strings to use [Private IP for Peering connection strings.](https://www.mongodb.com/docs/atlas/reference/faq/connection-changes.md#std-label-connstring-private)

- [Disable Peering-Only mode.](https://www.mongodb.com/docs/atlas/reference/faq/connection-changes.md#std-label-disable-peering-mode)

- Connect using the strings outlined in [Why does my cluster have multiple connection strings.](https://www.mongodb.com/docs/atlas/reference/faq/connection-changes.md#std-label-atlas-faq-multi-conn-strings)

**Note:**

You *can* keep connecting to your clusters using existing peering-enabled connection strings at this time. Peering-Only mode prevents access to the improved functionality and reduced limitations of multiple horizons. To use the new features and remove the legacy limitations, MongoDB requires that you use the new connection strings.

## Can my VNet-peered Azure (Microsoft Azure) cluster span multiple regions?

Yes.

Change your applications to connect using the [Private IP for Peering connection string](https://www.mongodb.com/docs/atlas/reference/faq/connection-changes.md#std-label-connstring-private). This change allows your applications to connect from peered networks using the UI or API.

To expand into more regions, disable Peering-Only mode on existing Azure (Microsoft Azure) clusters first.

## How do I disable peering-only mode?

To disable Peering-Only mode using the:

### Atlas Console

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. Update All Applications to Use Private IP for Peering Connection Strings.

   Change any URL (Uniform Resource Locator)s in your applications that use your Atlas clusters to use [Private IP for Peering connection strings.](https://www.mongodb.com/docs/atlas/reference/faq/connection-changes.md#std-label-connstring-private)

3. In Atlas, go to the Project Settings page.

   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 the  icon next to Project Overview.

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

4. Disable Connect via Peering Only.

   Toggle Connect via Peering Only (GCP and Azure) to Off.

## How does this affect AWS (Amazon Web Services) VPC (Virtual Private Cloud) peering when I use custom DNS (Domain Name System)?

Before 31 March 2020, applications deployed within AWS (Amazon Web Services) using custom DNS (Domain Name System) services and VPC (Virtual Private Cloud)-peered with Atlas couldn't connect over private IP addresses:

- Custom DNS (Domain Name System) resolved to public IP addresses.

- AWS (Amazon Web Services) internal DNS (Domain Name System) resolved to private IP addresses.

Applications deployed with custom DNS (Domain Name System) services in AWS (Amazon Web Services) should use [Private IP for Peering connection strings.](https://www.mongodb.com/docs/atlas/reference/faq/connection-changes.md#std-label-connstring-private)

To show these strings:

1. In Atlas, go to the Project Settings page.

   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 the  icon next to Project Overview.

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

2. Show the connection string.

   Toggle Using Custom DNS on AWS with VPC Peering to On.

   View the connect modal for your AWS (Amazon Web Services) cluster.

   Select the Private IP for Peering connection string.

### Standard Connection Strings

Standard connection strings follow this format:

```sh
mongodb://xyz456-shard-00-00.ab123.mongodb.net:27017
mongodb+srv://xyz456.ab123.mongodb.net
```

The dot before `ab123` *matters*. URI (Uniform Resource Identifier)s using this format resolve to public IP addresses *except* when connecting from inside AWS (Amazon Web Services) with VPC (Virtual Private Cloud)-peering configured.

**Important:**

This format changes one character from the [Legacy Connection Strings](https://www.mongodb.com/docs/atlas/reference/faq/connection-changes.md#std-label-connstring-legacy): a hyphen (`-`) after the cluster name becomes a period (`.`).

For example, this *legacy connection string*:

```sh
mongodb+srv://xyx456-ab123.mongodb.net
```

is written as this *standard connection string*:

```sh
mongodb+srv://xyx456.ab123.mongodb.net
```

For new clusters, replica sets and shards don't derive their name from the name of the cluster. The new names use a six alphanumeric character ID.

### Private Connection Strings

Private connection strings follow this format:

```sh
mongodb://xyx456-shard-00-00-pri.ab123.mongodb.net:27017
mongodb+srv://xyx456-pri.ab123.mongodb.net
```

The `-pri` before `ab123` *matters*. URI (Uniform Resource Identifier)s using this format resolve to private IP addresses reachable within the peered network. If you configure network peering for your cluster, you must use the new hostname when you connect to your cluster to utilize the peering.

**Important:**

In new clusters, replica sets and shards don't derive their name from the name of the cluster. The new names use a six alphanumeric character ID.

**Note:**

In AWS environments, the `-pri` connection string is optional, even when network peering is enabled. AWS resolves the cluster's private IP addresses whether you use the private or standard connection string.

### AWS (Amazon Web Services) Privatelink Connection Strings

[AWS PrivateLink](https://www.mongodb.com/docs/atlas/security-private-endpoint.md#std-label-private-endpoint-connection-strings) connection strings follow this format:

```sh
mongodb://pl-0-us-east-1a.ab123.mongodb.net:1024
mongodb+srv://pl-0-us-east-1a.ab123.mongodb.net
```

If you enable the [regionalized private endpoint](https://www.mongodb.com/docs/atlas/security-private-endpoint.md#std-label-atlas_regionalized-pl) setting, AWS PrivateLink connection strings follow this format:

```sh
mongodb://pl-0-us-west-1.ab123.mongodb.net:1024
mongodb+srv://cluster0-pl-0-us-west-1.ab123.mongodb.net
```

URI (Uniform Resource Identifier)s using this format can be reachable via the AWS (Amazon Web Services) VPC (Virtual Private Cloud) where someone configured PrivateLink, though access can be transitive from other VPC (Virtual Private Cloud)s peered in turn.

### Azure (Microsoft Azure) Private Link Connection Strings

[Azure Private Link](https://www.mongodb.com/docs/atlas/security-private-endpoint.md#std-label-private-endpoint-connection-strings) connection strings follow this format:

```sh
mongodb://pl-0-eastus2.ab123.mongodb.net:1024
mongodb+srv://pl-0-eastus2.ab123.mongodb.net
```

If you enable the [regionalized private endpoint](https://www.mongodb.com/docs/atlas/security-private-endpoint.md#std-label-atlas_regionalized-pl) setting, Azure Private Link connection strings follow this format:

```sh
mongodb://pl-0-eastus2.ab123.mongodb.net:1024
mongodb+srv://cluster0-pl-0-eastus2.ab123.mongodb.net
```

URI (Uniform Resource Identifier)s using this format can be reachable via the Azure (Microsoft Azure) VNet where someone configured Private Link, though access can be transitive from other VNets peered in turn.

### Legacy Connection Strings

Before 31 March 2020, you wrote Atlas connection strings as follows:

| AWS (Amazon Web Services) | `foo-shard-00-00-ab123.mongodb.net
foo-ab123.mongodb.net` |
| --- | --- |
| Azure (Microsoft Azure) | `foo-shard-00-00-ab123.azure.mongodb.net
foo-ab123.azure.mongodb.net` |
| Google Cloud | `foo-shard-00-00-ab123.gcp.mongodb.net
foo-ab123.gcp.mongodb.net` |

If you enabled **Private Only** mode, these hostnames resolve to peered network IP addresses. If you disabled that mode, hostnames resolve to public IP addresses.

If your application uses a legacy connection string in **Peering Only** mode, switch to [Private IP for Peering connection strings.](https://www.mongodb.com/docs/atlas/reference/faq/connection-changes.md#std-label-connstring-private)

## How can I optimize connection performance for sharded clusters using private endpoints?

Atlas can generate an optimized SRV (DNS Service Record) connection string for sharded clusters using the load balancers from your private endpoint service. When you use an optimized connection string, Atlas limits the number of connections per `mongos` between your application and your sharded cluster. The limited connections per `mongos` improve performance during spikes in connection counts.

To use an optimized connection string, you must meet all of the following criteria:

- [Configure a sharded cluster.](https://www.mongodb.com/docs/atlas/cluster-additional-settings.md#std-label-cluster-option-sharding)

- Ensure that the sharded cluster runs on AWS (Amazon Web Services).

- Ensure that the sharded cluster runs MongoDB version 5.0 or later. If your cluster currently runs an earlier version of MongoDB, [upgrade your cluster's MongoDB version](https://www.mongodb.com/docs/atlas/tutorial/major-version-change.md#std-label-upgrade-major-MongoDB-version) to version 5.0 or later to use an optimized SRV (DNS Service Record) connection string.

- [Set up a private endpoint](https://www.mongodb.com/docs/atlas/security-cluster-private-endpoint.md#std-label-cluster-private-endpoint) for your cluster.

- Use either:

  - A single-region cluster or

  - A multi-region cluster with [regionalized private endpoints](https://www.mongodb.com/docs/atlas/security-private-endpoint.md#std-label-atlas_regionalized-pl) enabled. Only the AWS (Amazon Web Services) regions in a multi-region cluster support an optimized SRV (DNS Service Record) connection string.

  Atlas doesn't support optimized connections to multi-region clusters using a single SRV (DNS Service Record) record.

- Connect using one of the following methods:

  - Connect using a driver that meets or exceeds the [minimum driver version for optimized connections.](https://www.mongodb.com/docs/atlas/driver-connection.md#std-label-driver-version-opt-connection)

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

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

**Note:**

If your cluster meets the criteria for optimized SRV (DNS Service Record) strings, Atlas generates an Optimized SRV Connection string for you. If your cluster ever had legacy connection strings, Atlas maintains those strings indefinitely and includes a Legacy SRV Connection string when you select the Private Endpoint connection type. Consider switching to the Optimized SRV Connection for optimal performance and update your connection string wherever you use it.

If you create the cluster and enable private endpoints after Atlas released this feature, Atlas displays the optimized connection string by default when you select the Private Endpoint connection type. You can identify an optimized connection string by the addition of `lb` to the connection string as shown in the following example:

`mongodb+SRV://User1:P@ssword@cluster0-pl-0-lb.oq123.mongodb-dev.net/`

To disable optimized connection strings for clusters that don't have the Legacy SRV Connection option, [contact support.](https://www.mongodb.com/docs/atlas/support.md#std-label-request-support)

**Warning: Converting to a Multi-Region Cluster**

If you convert your single-region sharded cluster to a multi-region cluster without enabling regionalized private endpoints, you cannot continue to use the optimized connection string. Before converting your cluster, update your connection string to the Legacy SRV Connection string described in the preceding note.

### Use Optimized Connection Strings with a Driver

To learn how to connect using a driver and an optimized connection string, select the Private Endpoint Connection tab in the [Connect Your Application procedure.](https://www.mongodb.com/docs/atlas/driver-connection/#choose-your-connection-security)

### Use Optimized Connection Strings with Compass

To learn how to connect using Compass and an optimized connection string, select the Private Endpoint Connection tab in the [Connect to your Cluster procedure.](https://www.mongodb.com/docs/atlas/compass-connection/#choose-your-connection-security)

### Use Optimized Connection Strings with `mongosh`

To learn how to connect using `mongosh` and an optimized connection string, select the Private Endpoint Connection tab in the [Connect to your Cluster procedure.](https://www.mongodb.com/docs/atlas/mongo-shell-connection/#choose-your-connection-security)

## Should I update the connection string if I change cloud provider on a Free or Flex cluster?

If you have a [legacy connection string](https://www.mongodb.com/docs/atlas/reference/faq/connection-changes.md#std-label-atlas-faq-connstring-legacy) and you want to change cloud providers, your connection string must include `.gcp` or `.azure` and you want to do one of the following:

- Move to Google Cloud or Azure (Microsoft Azure)

- Move off of Google Cloud or Azure (Microsoft Azure)

  **Note:**

  Either operation may change your connection string. In the Atlas UI, click Connect on your cluster after the upgrade completes for an updated connection string.

## Should I update the connection string if I change cloud provider on a dedicated cluster?

It depends on the following:

- which cloud provider your current cluster uses

- when you created the cluster

### GCP or Azure Clusters Created Before November 3, 2020

If you created your cluster before multi-cloud clusters were introduced on November 3, 2020, **and** your cluster runs on Google Cloud or Azure (Microsoft Azure):

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.

Open the cluster builder.

Edit the cluster.

Add read-only nodes from your target cloud provider.

**Note:**

If you are using legacy backups, keep one node in your current cloud provider, and move the rest to your target cloud provider.

Review and submit the changes.

Copy the resulting comma-delimited URI (Uniform Resource Identifier) connection string.

Replace the connection string in your application with this new [standard connection string.](https://www.mongodb.com/docs/atlas/reference/faq/connection-changes.md#std-label-atlas-faq-connstring-standard)

This allows your application to connect to nodes from multiple cloud providers.

Restart your application.

Make sure that your application can connect to Atlas.

After the first change completes, reconfigure your cluster:

- Remove all electable nodes using the original cloud provider.

- Remove the read-only nodes for the target cloud provider.

- Add the same number of electable nodes using the target cloud provider.

**Note:**

If you are using legacy backups, wait until new backups are taken, then move the remaining node to your target cloud provider.

Review and submit the changes.

Copy the resulting comma-delimited URI (Uniform Resource Identifier) connection string.

Replace the URI (Uniform Resource Identifier) connection string in your application with this new URI (Uniform Resource Identifier) connection string.

Restart your application.

Make sure that your application can connect to Atlas.

### AWS and Clusters Created After November 2, 2020

Your connection string doesn't change and you don't experience cluster downtime if any of the following is true:

- Your cluster runs on AWS (Amazon Web Services).

- Your cluster runs on any cloud provider but was created after November 2, 2020.

To change the cloud provider for your cluster:

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.

Open the cluster builder.

Edit the cluster.

Change the cloud provider.

Review and submit the changes.
