Practice: Connecting to Atlas · MongoDB

Ch 1 · MongoDB Atlas and Cloud Deployment — card 3 of 4.

Here you set up your own free cluster and connect to it from Node.js. You will create the cluster, copy its connection string, add your password, and fill in the run function so it connects, pings, inserts and finds a document. A working answer prints a success message, proving your user, password and network access are all configured correctly.

  1. Set up a free Atlas cluster
  2. Get the connection string
  3. Connect from a Node.js script
const { MongoClient } = require("mongodb");
// Replace with your Atlas URI
const uri = "mongodb+srv://...";

async function run() {
  // Connect, ping, insert, find
}
run();