Try Studio 3T for Free
  1. Knowledge Base
  2. MongoDB Tutorials
  3. How to Connect to MongoDB Atlas

How to Connect to MongoDB Atlas

What is MongoDB Atlas?

MongoDB Atlas is MongoDB’s own fully-managed global cloud database-as-a-service, which can be run on Amazon Web Services (AWS), Google Cloud Platform, or Microsoft Azure.

In this post, we’ll show you how to connect to MongoDB Atlas, MongoDB’s fully-managed DBaaS, using Studio 3T.

Don’t have a MongoDB Atlas account? Here’s a tutorial on how to set up a free M0 cluster.

If you’re having issues connecting to MongoDB Atlas, we recommend our troubleshooting guide instead.

Prerequisites

  1. Get your first MongoDB Atlas cluster for free.
  2. Download the latest Studio 3T version on your Windows, Mac, or Linux machine.
What's included in a free MongoDB Atlas cluster?

The free cluster includes:

  • 512 MB of storage
  • Shared RAM
  • Highly available replica sets, end-to-end encryption, automated patches, REST API
  • Max connections: 100
  • Network performance: Low
  • Max databases: 100
  • Max collections: 500

The free tier cluster regions available are:

  • N. Virginia (us-east-1)
  • Frankfurt (eu-central-1)
  • Singapore (ap-southeast-1)
  • Mumbai (ap-south-1)

1. Get the connection string from MongoDB Atlas

Log in to your MongoDB Atlas account. This will take you to your Clusters overview.

Click on Connect.

Click on Connect in the Clusters overview

Choose Connect Your Application.

Choose Connect Your Application

Choose your driver and driver version. We use Java and Version 3.7 or later in this example, but the latest version of any driver should also generate a compatible connection string.

Choose the MongoDB driver and version

Copy the generated connection string. This is what you’ll need to paste in Studio 3T.

Copy the MongoDB Atlas connection string

2. Whitelist your IP address

If you have a dynamic IP address – which most of us do – it’s worth double-checking the MongoDB Atlas IP Whitelist tab.

Click on Network Access under the Security tab on the left-hand sidebar. This will take you to the IP Whitelist tab.

Click on Add IP Address in the top-right corner. This will open the Add IP Whitelist Entry dialog.

MongoDB Atlas IP whitelist tab

Click on Add current IP address. MongoDB will automatically detect your current address, then click Confirm.

Add current IP address in MongoDB Atlas

Are you connecting from another IP address, through a VPN, or getting errors? Troubleshoot MongoDB Atlas connection issues with our guide.

3. Connect to Studio 3T

Open Studio 3T and click on Connect in the top-left corner of the toolbar. This will open the Connection Manager.

Click on New Connection in the top-left corner, which will open a new connection window.

connect using the connection manager

Name your connection and click on the From URI button.

Name the connection and click the From URI button

Paste the connection string you copied from MongoDB Atlas.

Replace the placeholder “<password>” with your actual password and “<dbname>” with the name of the database that connections will use by default. Make sure to replace the brackets too, and click OK.

Paste the MongoDB connection string

Studio 3T will automatically extract the information and pre-populate the fields in the Server, Authentication, SSL, SSH Tunnel, and Advanced tabs. It will also save the connection for later use.

Click through the Server, Authentication, SSL, and SSH Tunnel tabs and verify that the information is correct.

Click on Test Connection. A successful test will look like this:

Test MongoDB Atlas connection

Click Save. Then click Connect.

If you’re getting a connection error, e.g. Prematurely reached end of stream, make sure your IP address has been whitelisted on MongoDB Atlas.

4. Import data in JSON, CSV, BSON/mongodump or SQL

If you have an empty cluster, you can easily import JSON, CSV, BSON/mongodump or SQL to MongoDB with Studio 3T’s Import Wizard:

5. Explore MongoDB data

Click on a collection in the Connection Tree to open a Collection Tab, which is the starting point of all data exploration in Studio 3T.

Click on a connection in the Connection Tree

Here you can view the contents of your MongoDB collection in either Table View, Tree View, or JSON View:

Easily edit data in Table, Tree, and JSON view.

Or access the Visual Query Builder, a drag-and-drop MongoDB query builder ideal for both newcomers and pros:

Once you’ve built your query, click on Query Code tab to see how it translates to Java, Node.js, PHP, C#, Python, Ruby, and the mongo shell language:

Translate your query from the mongo Shell language into: JavaScript, Java, C#, Python, Ruby, and PHP.

And that’s just one way of querying data in Studio 3T. There’s also IntelliShell, the built-in mongo shell with robust auto-completion; Aggregation Editor, the stage-by-stage aggregation query builder; and SQL Query, which lets you write SQL to query your MongoDB database.

Updated on September 24, 2020

Was this article helpful?

Comments

  1. While connecting to MongoDB Atlas with Studio 3T 2020.3.1
    (plus using SSH Tunnel to our IP Whitelisted server)

    The connection timeout with error:
    Mongo Server error (MongoCommandException): Command failed with error 8000 (AtlasError): ‘no SNI name sent, make sure using a MongoDB 3.4+ driver/shell.’ on server xxxxxx

    I could see it somewhere that Studio 3T uses legacy version of Java Mongodb Driver.
    How can I solve this problem?

  2. Hi Ittipan,

    Many thanks for reaching out! Are you trying to establish a SSL connection with SNI? As a next step, it would be great if you could you please send us a screenshot of your connection configuration at support at studio3t dot com and we’d be happy to investigate further.

    Best,
    Kathryn

  3. Hello , i have both mongo and mongo atlas in my java application. Can you please tell me how to find which one is mongodb and which is atlas version via java code ?
    Thanks..

    1. Hi Rajat,

      From a Java point of view, one won’t be able to distinguish which one is which. This seems to be more of a Java driver question. Sorry we couldn’t help further.

      Best,
      Kathryn

  4. I cannot find the connection setup as described here. The only “Connect” button I can find in Atlas is on a cluster, but it asks me to white-list an IP first. Which is not suitable for a connection from a home PC.

    1. Hi Tom,

      Many thanks for flagging that – we will update the article accordingly. In the meantime, yes, you would need to whitelist your home IP address on the MongoDB Atlas interface following these steps.

      Hope this helps,
      Kathryn

    2. Hi Tom,

      We’ve updated the article – hope you managed to connect in the meantime.

      Best,
      Kathryn

  5. Hey,
    I am trying to connect to an old application that doesn’t support the SRV record redirect.
    Is there a way to get a direct DB URI ?
    Thanks,
    Ran

Leave a Comment