Docs Menu

Docs HomeMongoDB Compass

Connect to MongoDB

On this page

  • Considerations
  • Connect
  • Advanced Connection Options

This page outlines how to use MongoDB Compass to connect to a MongoDB host. You can connect to a standalone, replica set, or sharded cluster host.

Note

MongoDB Atlas

If you need to create a MongoDB host, consider using MongoDB Atlas. Atlas is a cloud-hosted database-as-a-service which requires no installation, offers a free tier to get started, and provides a copyable URI to easily connect Compass to your deployment.

If you need to install Compass, see Download and Install Compass for instructions.

  • When connecting Compass to a replica set, it is not recommended to connect directly to an individual replica set member. If the member to which you are connected switches from a primary member to a secondary or vice versa as the result of an election, Compass may either forcibly close the connection or display stale data.

    Instead, to connect to a replica set, use either the replica set SRV record or Replica Set Name when filling in your connection information.

  • Starting in MongoDB Compass 1.19, Compass displays a warning message when connected to non-genuine MongoDB instances as these instances may behave differently from the official MongoDB instances; e.g. missing or incomplete features, different feature behaviors, etc.

When you open Compass, an initial connection dialog appears:

New connection dialog for pasting your connection string

You can connect your deployments by either:

  • Providing your connection string.

  • Specifying Advanced Connection Options. Advanced connection options allow you to specify authentication, TLS/SSL, and SSH connection options. To learn more, see Advanced Connection Options.

When you provide a connection string, Compass supports most Connection String Options supported by MongoDB.

By default, Compass's default socketTimeoutMS value is 60000, or 60 seconds. If you are frequently experiencing timeouts in Compass, consider setting this option to a higher value in your connection string.

For a complete list of the connection string options that Compass supports, see the Compass Connection README on GitHub.

1

If you have the connection string for your deployment available, you can paste the string directly into the dialog box. You can use either the Standard Connection String Format or the DNS Seedlist Connection Format.

  • To obtain the connection string for an Atlas cluster:

    1. Navigate to your Atlas Clusters view.

    2. Click Connect for your desired cluster.

    3. Click Connect with MongoDB Compass.

    4. Copy the provided connection string.

  • To learn how to format the connection string for a deployment which is not hosted on Atlas, see Connection String URI Format.

2

Click the Connect button to navigate to the Compass Home Page.

Important

Required Access

Once you are connected to your MongoDB deployment, you may require specific user roles to access various Compass features. For more information on the required roles for Compass features, see Required Access.

The Advanced Connection Options provide additonal forms of connecting Compass deployments.

General Connection Tab
Learn how to select a Connection String Scheme for your deployment.
Authentication Connection Tab
Learn how to connect deployments that require authentication.
TLS / SSL Connection Tab
Learn how to connect deployments using TLS/SSL.
Proxy / SSH Tunnel Connection Tab
Learn how to connect deployments using an SSH tunnel.
In-Use Encryption Connection Tab
Learn how to connect deployments using In-Use Encryption.
Advanced Connection Tab
Learn about additional advanced connection options for your deployments.

Tip

See also:

To learn how to disconnect your deployment, see Disconnect from MongoDB

←  Capabilities of Compass EditionsGeneral Connection Tab →
Give Feedback
© 2022 MongoDB, Inc.

About

  • Careers
  • Investor Relations
  • Legal Notices
  • Privacy Notices
  • Security Information
  • Trust Center
© 2022 MongoDB, Inc.