CoderSathi
  • Tutorial
    • Java Tutorial
    • Swing Tutorial
    • JDBC Tutorial
    • Java String Tutorial
    • Servlet and JSP Tutorial
  • Mongo DB
  • AWS
  • DevOps
  • Linux
  • Git
Home > How to > Connect MongoDB Atlas Cluster Using Shell

Connect MongoDB Atlas Cluster Using Shell

Learn the concepts, implementation details, and practical steps with a clean developer-focused walkthrough.

Yuba Raj Kalathoki
By Yuba Raj Kalathoki
Last updated: July 1, 2026 · 3 min read · 0 Comments
Share: in X
Connect MongoDB Atlas Cluster Using Shell

In this post, we will learn to connect the MongoDB Atlas cluster using a shell command from our local machine.

To connect a cluster we must have:

  1. A cluster is created in Atlas. If you haven’t created it already you can visit my previous post Create Cluster In MongoDB Atlas and
  2. We must have a MongoDB shell installed on our computer. If you haven’t installed a MongoDB shell on your computer then you can visit The Mongo Shell and follow the steps given there.

Table of Contents

Verify MongoDB Shell Version
Connect cluster using MongoDB Shell
List databases
Error: queryTxt ETIMEOUT
Summary

Verify MongoDB Shell Version

Open your Terminal or Command Prompt if you are using a Windows machine and type:

mongo --version

If MongoDB shell is already installed on your computer you may see output like:

MongoDB shell version v5.0.4
Build Info: {
    "version": "5.0.4",
    "gitVersion": "62a84ede3cc9a334e8bc82160714df71e7d3a29e",
    "modules": [],
    "allocator": "tcmalloc",
    "environment": {
        "distmod": "windows",
        "distarch": "x86_64",
        "target_arch": "x86_64"
    }
}

It is confirmed that the MongoDB Shell is installed on our machine.

Hence, let us start connecting to Atlas Cluster from our computer using MongoDB Shell.

Connect cluster using MongoDB Shell

  1. Go to your Database Deployments and select your cluster. In our case Sandbox is the cluster where we are trying to connect.
Image 26
  1. Click Connect button on the right side. (You can directly click connect from step 1 as well. Both options are the same.)
Image 27
  1. In the new window, we can see many options to connect. In this tutorial, we are trying to connect from MongoDB Shell. Hence, click on this.
Image 28
  1. After clicking Connect with the MongoDB Shell it asks us to download the Mongosh. Since we have already installed MongoDB Shell which is the Prerequisite we don’t have to download and install it. If you haven’t already then you may download it from here. The only difference will be the command. You will see this in the next step. In the following screen, copy the connection string by clicking on the copy icon as shown. See the image below to understand it more clearly.
Image 29
  1. I assume that you’ve copied the connection string but if you have installed MongoDB Shell the connection string would be:
mongo "mongodb+srv://sandbox.7dtrvh3.mongodb.net/myFirstDatabase" --apiVersion 1 --username codersathi

And if you’ve installed the Mongosh then the connection would be:

mongosh "mongodb+srv://sandbox.7dtrvh3.mongodb.net/myFirstDatabase" --apiVersion 1 --username codersathi

If you have noticed on these two connection strings only the difference is mongo and mongosh.

  1. You can see the following screen when you paste the connection string into your command line or terminal

On my computer I’ve installed MongoDB Shell hence I will be using the following command:

mongo "mongodb+srv://sandbox.7dtrvh3.mongodb.net/myFirstDatabase" --apiVersion 1 --username codersathi
Image 30

After pasting the connection string in the command line or terminal it asks for the password. Enter the correct password.

Once the password is matched you may see the following in your terminal.

Image 31

It means that the connection to our Atlas Cluster is successful.

List databases

In this section, we will be using the following command to see a list of available databases in our MongoDB database cluster.

show databases

By using, the above command we can see the list of databases.

Since we’ve already connected to our MongoDB Atlas cluster using MongoDB Shell let’s see the databases available there.

Image 32

It shows all the available databases there.

Error: queryTxt ETIMEOUT

While connection to Atlas sometimes, we may see connection timeout error. And this error is very common.

If you encounter this error then our another post DNSHostNotFound: Failed to look up service “”: DNS name does not exist issue while connecting to MongoDb Atlas may help.

Summary

In this post, we learned to connect MongoDB Atlas Cluster using the MongoDB shell and we also learned to see the list of databases available there.

Related Posts:

  • How to Connect MongoDB Atlas Using Compass -…
  • How to Solve “systemctl command not found” Error: A…
  • Install MongoDB BI Connector on Ubuntu
  • Command Line Arguments in Java
  • How to Upload File to AWS EC2 Instance From Local Machine?
  • MySQL Commands for Developers
Tags:mongodbmongodb-atlas
Was this article helpful?
← Previous ArticleCreate Cluster In MongoDB Atlas
Next Article →Sort List of Objects in Java

Leave a Comment Cancel reply

You must be logged in to post a comment.

Recent Posts

  • How to implement Passwordless Authentication in Spring Boot: A Step-by-Step Guide
  • How to Use AWS CloudFront Signed URLs in Spring Boot?
  • How to Fix SSH Agent Forwarding on macOS: The Ultimate Guide for Developers
  • How to Read AWS Secrets Manager in Spring Boot (Step-by-Step)
  • How to Fix “Public Key Retrieval is not allowed” MySQL JDBC Error
CoderSathi

Your go-to resource for Java, Spring Boot, Microservices, AWS, and modern development tutorials.

Linkedin

Quick Links

  • About
  • Contact

Popular Topics

  • Java
  • Spring Boot
  • AWS
  • DevOps
  • MongoDB
  • Linux
  • Git
  • How to
© 2026 CoderSathi. All rights reserved. Privacy Policy · Sitemap