Cannot connect to cluster using mongoshell

(MongoDB shell version v4.0.10)
I follow instruction, enter below command:
mongo mongodb+srv://
It failed. Part of the error message is:
*** It looks like this is a MongoDB Atlas cluster. Please ensure that your IP whitelist allows connections from your network.
I do whitelist using “ALLOW ACCESS FROM ANYWHERE”
If I remove the last piece “/test”, I can connect, but the prompt is:
MongoDB Enterprise mflix-shard-0:SECONDARY>

Hi @tien_nguyen,

You need to replace this with the cluster command from
Steps to do :

  1. Login to
  2. Select your cluster.
  3. Click Connect
  4. Connect with Mongo Shell
  5. Copy the command from there and then try again.

Let me know if that helps.


Thanks, Kanika. Your instructions are exactly the same as in the course. I tried once again and the issue still exists. The command is:
mongo “mongodb+srv://” --username m220student

As said earlier, if I remove the last piece ‘/test’, I can connect, but only to the SECONDARY

Hi @tien_nguyen,

Oh! Can you please share the screenshot of your command line / terminal ?


Remove last piece ‘/test’

I have similar kind of problemCluster_connection_err

Hi @Sreekumar_85793,

I am able to connect using the below command:

  mongo mongodb+srv://

Please make sure your firewall is not enabled. And your network should allow request from this cluster.


I think the problem is your user is not a cluster Admin. The readme asked us to create one user with only readAndWrite permission.

Try logging into your Atlas Cluster from the web, create an Atlas Admin user then connect through shell with that credential.

I got the same warning when I try to connect using the connect string for this course. Still I don’t know why I got the PRIMARY. Let’s wait for our support engineer to diagnose the issue.

Primary is correct
You always connect to primary
Please ignore those warning messages
Yes as you said user should have more privileges(R/W) to avoid seeing those warning essages
I tried your commands both with and without test
Able to connect fine
C:\Users\ramrt>mongo “mongodb+srv://” --username m220student --password m220password
MongoDB shell version v4.0.5
connecting to: mongodb://,,
MongoDB server version: 4.0.10
Error while trying to show server startup warnings: user is not allowed to do action [getLog] on [admin.]
MongoDB Enterprise mflix-shard-0:PRIMARY> db
MongoDB Enterprise mflix-shard-0:PRIMARY>

Solved. It was issue with port 27017.Thank you

My issue is due to the DNS. Credit is due to Quang_80634 who helped me out in another topic.