How does mongodb connect to atlas?

Docs HomeMongoDB Atlas

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 to modify its number of nodes or regions.

To access a database deployment, 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. You can also add the IP address from the Network Access tab.

To access a database deployment, you must create a database user with access to the desired database(s) on your Atlas database deployment. 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 database deployment in the Connect dialog. You can also add the database user from the Database Deployment view.

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 to add private IP addresses.

  3. Add private endpoints.

Tip

See also:

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 traffic on Atlas hosts. This grants your applications access to databases stored on Atlas.

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, you must allow network access from Atlas clusters directly to your secure LDAP. You can allow access to your LDAP by using public or private IPs as long as a public DNS hostname points to an IP that the Atlas clusters can access.

If you are not using VPC / VNet 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?

  • Do Atlas clusters' public IPs ever change?

Note

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

Tip

See also:

  • Connect via Your Application

  • Connect via Compass

  • Connect via mongosh

  • Connect via BI Connector for Atlas

  • Browse Data via the Atlas UI

  • Test Failover

  • Manage Connections with AWS Lambda

  • Connection Limits and Cluster Tier

Docs HomeMongoDB Atlas

Estimated completion time: 5 minutes

You can connect to your cluster in a variety of ways. This tutorial describes how to connect to your cluster using the mongosh, the Node.js driver, the PyMongo driver, and Compass.

  • An Atlas account.

  • An organization and project added with an account's user who has permissions to create clusters in this account.

  • An active cluster created in this account.

  • An IP address added to your IP access list.

  • A Database user on your cluster.

See Parts 1 - 4 of this tutorial for help with the prerequisites.

Note

You must have a database user set up on your cluster to access your deployment. For security purposes, Atlas requires clients to authenticate as database users to access clusters.

The following steps show you how to download and install the mongosh, the Node.js driver, and the PyMongo driver.

Before you start, verify that you have met all prerequisites.

Select the appropriate tab based on how you would like to connect to your cluster:

In Atlas, you can connect to your cluster using the following connection methods:

  • Connect with the MongoDB Shell to interact with your cluster using the Javascript interface of mongosh.

  • Connect your application to your cluster using the Node.js driver, or the PyMongo driver.

  • Connect to your cluster using MongoDB Compass to explore, modify, and visualize your data with Compass.

Before you start, verify that you have met all prerequisites.

Select the appropriate tab based on your preferred connection method:

Now that you are connected to your cluster, proceed to Insert and View Data in Your Cluster.

How does MongoDB connect to Atlas Compass?

Open MongoDB Compass and Connect to Atlas..
Click New Connection and paste the connection string into the Paste your connection string field..
(Optional) To save this connection for future use, click Create Favorite and add a name for this connection. ... .
Click Connect..

How does MongoDB connect to database?

How to connect to MongoDB.
Create database on MongoDB. Connect to MongoDB shell. Create "testdb" database. Create "user" collection and insert it to "testdb"..
User Settings. Connect to admin db. Create user administrator. ... .
Create connection to MongoDB on CPD. Set the required information..

How does MongoDB connect to Atlas to Python code?

You'll need to get your cluster's connection string from Atlas to connect to the cluster using the PyMongo driver..
Click Connect. ... .
Click Choose a connection method..
Click Connect your application. ... .
Select Python and your version of the driver. ... .
Copy the provided connection string..
Configure the provided connection string..

Is MongoDB and MongoDB Atlas same?

MongoDB was also designed for high availability and scalability, with built-in replication and auto-sharding; MongoDB Atlas: Deploy and scale a MongoDB cluster in the cloud with just a few clicks. MongoDB Atlas is a global cloud database service built and run by the team behind MongoDB.