Atlas is the MongoDB database as a service offering. With Atlas, you can create fully managed MongoDB databases on AWS, Google Cloud, and Azure. If you have been playing around with MongoDB locally you will know how trivially easy it is for clients and servers to connect.
Servers listen by default on port 27017 and clients by default expect to connect to localhost:27017. With Atlas, we need to connect to a remote server that expects both a username and password and an SSL connection. But don’t worry Atlas makes this super easy to configure.
First login to your Atlas cluster at cloud.mongodb.com. Here is my login page.
Now click the connect button. This will pop up the following screen.
You want to scroll down to the Connect Your Application and click there.
This will open up the Connection string screen.
You now need to decide whether you are using the latest drivers (3.6) or an earlier version. When you originally created the cluster you selected a specific version of the server on the Create cluster page.
If you are using a 3.6 driver then the server will be configured to use the new seedlist configuration format.
If you click on that link you will get a window displaying the correct connection string.
This string is hard to read on the screenshot so we can reproduce it here.
mongodb+srv://jdrumgoole:<PASSWORD>@mugalyser-ffp4c.mongodb.net/test
For the 3.4 and earlier drivers, we use the old format MongoDB URI connection string.
mongodb://jdrumgoole:<PASSWORD>@mugalyser-shard-00-00-ffp4c.mongodb.net:27017,mugalyser-shard-00-01-ffp4c.mongodb.net:27017,mugalyser-shard-00-02-ffp4c.mongodb.net:27017/test?ssl=true&replicaSet=MUGAlyser-shard-0&authSource=admin
In both cases, you will need to supply the password that you created for your user. Note this is the password for the database, not your Atlas login password.