Connecting to a MongoDB Cluster

Learn how to connect to a MongoDB cluster using Atlas.

In this lesson, we’ll learn how to connect to a real MongoDB instance. Here, we’ll be using a service called Atlas. Atlas is a service from MongoDB that provides a cloud MongoDB database. Their free tier is quite generous and works well for our application. Create an account there. Once we’ve done that, we can create a MongoDB cluster.

Note: If you have any other MongoDB instance, local or remote, feel free to use it by skipping the next paragraph and going directly to inserting the database URI into the code.

The following link contains all the instructions needed to create a cluster and to get the connection cluster ID:

https://www.educative.io/answers/how-to-create-a-new-cluster-in-mongodb-atlas

Steps to create a user

Once the cluster has been created, we also need to create a user that has access to it.

It should look something like the following:

Get hands-on with 1400+ tech skills courses.