Connecting to your Atlas cluster starts with the CONNECT button, which can be found on the main Clusters page, just under the name of your cluster.
Step 1) Set Up Your IP Whitelist
Before attempting to connect to your Atlas cluster, you should first check the IP Whitelist information at the top of the modal, by clicking the [Connect] button. The IP Whitelist is the list of IPs from which connections to your cluster will be accepted. If your current IP is not on the list, you won't be able to connect!
Use the buttons to either "Allow Access From Anywhere", "Add Current IP" or add an arbitrary IP.
Step 2) Connect With The Mongo Shell
We recommend testing your connection with the Mongo Shell before moving on to set up your application. To find the connection string, look for the "Connect with the Mongo Shell" section of this modal.
If you don't have the mongo shell installed on your computer yet, download the shell. You can download the mongo shell right from the Connect modal. If you're using a version of the mongo shell already installed on your computer, make sure it's an updated version - Atlas requires near parity in versions (for example, if you are running MongoDB 3.4, you will need at least version 3.4.2 of the mongo shell). You can see your version of the shell by running mongo --version
.
Once you've got the latest version of the shell downloaded, use the COPY button to copy the connection string to your terminal. When you created your Atlas cluster, we build two databases within it, local
and admin
.
The admin database is your auth source (that is, the admin database will store your users and passwords). Once you've created your first user, this will construct your connection string. For example, if you've created a user called superuser, with a password of PASSWORD123, your connection string would have this syntax:
`mongodb://superuser:PASSWORD123@hostname:port,hostname:port,hostname:port/admin?ssl=true&replicaSet=primaryhostname&authSource=admin`