MDBU M001 class: can connect to Atlas with Compass but not with in-browser IDE

NOTE: the zzzzz below is my redacted five-letter sandbox identifier.

For the M001 Chapter 1 “Lab: Connect to your Atlas Cluster” I’m trying to connect from the in-browser IDE terminal window using the command and connection string shown below:

user@M001# mongo "mongodb+srv://sandbox.zzzzz.mongodb.net/sample_airbnb" --username m001-student
MongoDB shell version v4.0.5
Enter password:

After I type my password (which of course I swear I got right), I get the following:

connecting to: mongodb://sandbox-shard-00-00.zzzzz.mongodb.net.:27017,sandbox-shard-00-02.zzzzz.mongodb.net.:27017,sandbox-shard-00-01.zzzzz.mongodb.net.:27017/sample_airbnb?authSource=admin&gssapiServiceName=mongodb&replicaSet=atlas-bqf9mc-shard-0&ssl=true
2021-12-06T02:57:04.851+0000 I NETWORK  [js] Starting new replica set monitor for atlas-bqf9mc-shard-0/sandbox-shard-00-00.zzzzz.mongodb.net.:27017,sandbox-shard-00-02.zzzzz.mongodb.net.:27017,sandbox-shard-00-01.zzzzz.mongodb.net.:27017
2021-12-06T02:57:06.887+0000 W NETWORK  [ReplicaSetMonitor-TaskExecutor] Unable to reach primary for set atlas-bqf9mc-shard-0
2021-12-06T02:57:06.888+0000 I NETWORK  [ReplicaSetMonitor-TaskExecutor] Cannot reach any nodes for set atlas-bqf9mc-shard-0. Please check network connectivity and the status of the set. This has happened for 1 checks in a row.
2021-12-06T02:57:10.353+0000 W NETWORK  [js] Unable to reach primary for set atlas-bqf9mc-shard-0
2021-12-06T02:57:10.353+0000 I NETWORK  [js] Cannot reach any nodes for set atlas-bqf9mc-shard-0. Please check network connectivity and the status of the set. This has happened for 2 checks in a row.
<snip checks 3, 4 and 5>
2021-12-06T02:57:20.955+0000 E QUERY    [js] Error: connect failed to replica set atlas-bqf9mc-shard-0/sandbox-shard-00-00.zzzzz.mongodb.net.:27017,sandbox-shard-00-02.zzzzz.mongodb.net.:27017,sandbox-shard-00-01.zzzzz.mongodb.net.:27017 :
connect@src/mongo/shell/mongo.js:328:13
@(connect):1:6
exception: connect failed
user@M001# 

When I connect with Compass it works fine, and the replica set is the same as in the error messages above (atlas-bqf9mc-shard-0). The individual shards also have the same names (sandbox-shard-00-00.zzzzz.mongodb.net:27017, etc.). I use a slightly different connection string in Compass, embedding the username and password:

mongodb+srv://m001-student:m001-mongodb-basics@sandbox.zzzzz.mongodb.net/sample_airbnb

Connecting using the Browser IDE is a graded assignment so I’d like to complete it. According to another forum post one can use a different shell/IDE to complete the assignments, but that assertion wasn’t followed by an explanation so I’d prefer to use the in-browser IDE.

Thanks in advance. FWIW I’m a long-time RDBMS developer who’s dabbled in MongoDB using the C# and node.js clients, and I’m looking forward to learning it methodically through the MDBU classes. So far the M001 class has been excellent… until I hit this wall :expressionless:

Hello @Ed_Gibbs ,

Welcome to the MongoDB Community Forums.

Something is blocking your in-browser IDE to reach primary and any other nodes. Use “m001” instead of “sample_airbnb”.

Most likely it is related to network security. I suspect that you only added your public IP address to the allowed list. The IP address seen by the server is different than your workstation IP. You should allow from anywhere.

1 Like

Thank you Mohammad and Steeve! I did indeed have IP restrictions for my public address, but after removing them I still get the same error message. I’m still not 100% with the Atlas UI so in case I made the wrong setting – or the right setting in the wrong place – my Network Access screen after the IP removal is below. Anything jump out at you?

Also, here’s my full connection info. My company’s culture is to be extra paranoid about security so the earlier redaction was just me on auto-pilot. There’s really not much at stake here security-wise, and no point hobbling folks who are trying to help me.

mongo "mongodb+srv://sandbox.surrz.mongodb.net/sample_airbnb" --username m001-student --password m001-mongodb-basics

You have to allow access from anywhere.

To do that click Add IP Address and then ALLOW ACCESS FROM ANYWHERE. The text field Access List Entry will be filled with 0.0.0.0/0. Terminate by clicking Confirm.

3 Likes

Thank you Steeve! I’m connected now; all set.

My apologies for posting about a self-inflicted issue. Based on your answer I re-reviewed the “Lab: Create and Deploy an Atlas Cluster” segment and see this was a miss on my part: the “Allow Access from Anywhere” setting is clearly stated in step 10, bullet point #2.

1 Like

No apologies needed.

Simply mark one of the post as a solution so that others know.