Error while connecting via shell

I installed the ‘Community’ edition and then changed the path etc. I am following lesson2.3 part 1 and did the copy from the notes to connect via shell and getting the following error. Any thoughts?
Thanks
Ashok

2019-01-11T13:35:53.633-0500 E QUERY [js] SyntaxError: missing ; before statement @(shell):1:6

@Ashok_81119 Could you post what you typed from the notes? It looks like a syntax error.

[Edit:] FYI I think you need the enterprise edition for the class if I recall due to the schema feature not being in the Community Edition. If that has changed since I took the class then disregard this statement.

Hi Mike,

Thank you for taking it up.

I copied from the class notes as below and pasted on the shell:

mongo “mongodb://cluster0-shard-00-00-jxeqq.mongodb.net:27017,cluster0-shard-00-01-jxeqq.mongodb.net:27017,cluster0-shard-00-02-jxeqq.mongodb.net:27017/test?replicaSet=Cluster0-shard-0” --authenticationDatabase admin --ssl --username m001-student --password m001-mongodb-basics

will wait to hear back.
Thanks,
Ashok

Also giving below the screen shot of the shell as well:

Actually I found the problem. I was doing first ‘mongo --nodb’ which was from the previous class session.

When I removed that and just used the session note command it worked.
Thank you all.

Ashok

4 Likes

@Ashok_81119 Great! Yep they both launch the mongo shell, the former just uses the default settings and the second one would be for the class specific cluster. So in the second one, it was trying to launch the shell from within the shell which likely caused the syntax error.

1 Like

Thanks Mike. Your explanation cleared it up better.
Ashok

I cant login either am getting authetication error as below

am using MongoDB shell version v4.0.5

what user name password you are using? Make sure the credentials you are using have listed as valid user
Thanks,
Ashok

The credentials are valid and by the way i just copied and pasted the command from the lecture notes so should work

mongo "mongodb://cluster0-shard-00-00-jxeqq.mongodb.net:27017,cluster0-shard-00-01-jxeqq.mongodb.net:27017,cluster0-shard-00-02-jxeqq.mongodb.net:27017/test?replicaSet=Cluster0-shard-0" --authenticationDatabase admin --ssl --username m001-student --password m001-mongodb-basics

Roger that. I had to go back and change the authentication of that user level to highest unless you already have that in that case hope someone else can pitch in.
Thanks,
Ashok

Thank you am able to login now

good. so what was it?

Nothing I did on my side after your reply that you changed the authentication of user to highest i tried with the same command and it worked

Got it. Thanks for the feed back.
Ashok

Hi Ashok,
I was also doing the same mistake, and your post solved my problem too.

Thanks,
Muzaffar

Hi Muzaffar,

I am glad that it was helpful.

Thanks,

Ashok

1 Like

I can’t connect either. Getting the following output

mongo "mongodb://cluster0-shard-00-00-jxeqq.mongodb.net:27017,cluster0-shard-00-01-jxeqq.mongodb.net:27017,cluster0-shard-00-02-jxeqq.mongodb.net:27017/city?replicaSet=Cluster0-shard-0" --authenticationDatabase admin --ssl --username m001-student --password m001-mongodb-basics
MongoDB shell version v4.0.5
connecting to: mongodb://cluster0-shard-00-00-jxeqq.mongodb.net:27017,cluster0-shard-00-01-jxeqq.mongodb.net:27017,cluster0-shard-00-02-jxeqq.mongodb.net:27017/city?authSource=admin&gssapiServiceName=mongodb&replicaSet=Cluster0-shard-0
2019-01-16T12:57:36.568+0000 I NETWORK  [js] Starting new replica set monitor for Cluster0-shard-0/cluster0-shard-00-00-jxeqq.mongodb.net:27017,cluster0-shard-00-01-jxeqq.mongodb.net:27017,cluster0-shard-00-02-jxeqq.mongodb.net:27017
2019-01-16T12:57:37.067+0000 W NETWORK  [ReplicaSetMonitor-TaskExecutor] Unable to reach primary for set Cluster0-shard-0
2019-01-16T12:57:37.068+0000 I NETWORK  [ReplicaSetMonitor-TaskExecutor] Cannot reach any nodes for set Cluster0-shard-0. Please check network connectivity and the status of the set. This has happened for 1 checks in a row.
2019-01-16T12:57:38.179+0000 W NETWORK  [js] Unable to reach primary for set Cluster0-shard-0
2019-01-16T12:57:38.180+0000 I NETWORK  [js] Cannot reach any nodes for set Cluster0-shard-0. Please check network connectivity and the status of the set. This has happened for 2 checks in a row.
2019-01-16T12:57:39.308+0000 W NETWORK  [js] Unable to reach primary for set Cluster0-shard-0
2019-01-16T12:57:39.309+0000 I NETWORK  [js] Cannot reach any nodes for set Cluster0-shard-0. Please check network connectivity and the status of the set. This has happened for 3 checks in a row.
2019-01-16T12:57:40.431+0000 W NETWORK  [js] Unable to reach primary for set Cluster0-shard-0
2019-01-16T12:57:40.432+0000 I NETWORK  [js] Cannot reach any nodes for set Cluster0-shard-0. Please check network connectivity and the status of the set. This has happened for 4 checks in a row.
2019-01-16T12:57:41.555+0000 W NETWORK  [js] Unable to reach primary for set Cluster0-shard-0
2019-01-16T12:57:41.555+0000 I NETWORK  [js] Cannot reach any nodes for set Cluster0-shard-0. Please check network connectivity and the status of the set. This has happened for 5 checks in a row.
2019-01-16T12:57:45.677+0000 W NETWORK  [js] Unable to reach primary for set Cluster0-shard-0
2019-01-16T12:57:45.678+0000 I NETWORK  [js] Cannot reach any nodes for set Cluster0-shard-0. Please check network connectivity and the status of the set. This has happened for 6 checks in a row.
2019-01-16T12:57:46.795+0000 W NETWORK  [js] Unable to reach primary for set Cluster0-shard-0
2019-01-16T12:57:46.795+0000 I NETWORK  [js] Cannot reach any nodes for set Cluster0-shard-0. Please check network connectivity and the status of the set. This has happened for 7 checks in a row.
2019-01-16T12:57:47.912+0000 W NETWORK  [js] Unable to reach primary for set Cluster0-shard-0
2019-01-16T12:57:47.912+0000 I NETWORK  [js] Cannot reach any nodes for set Cluster0-shard-0. Please check network connectivity and the status of the set. This has happened for 8 checks in a row.
2019-01-16T12:57:49.023+0000 W NETWORK  [js] Unable to reach primary for set Cluster0-shard-0
2019-01-16T12:57:49.024+0000 I NETWORK  [js] Cannot reach any nodes for set Cluster0-shard-0. Please check network connectivity and the status of the set. This has happened for 9 checks in a row.
2019-01-16T12:57:50.152+0000 W NETWORK  [js] Unable to reach primary for set Cluster0-shard-0
2019-01-16T12:57:50.152+0000 I NETWORK  [js] Cannot reach any nodes for set Cluster0-shard-0. Please check network connectivity and the status of the set. This has happened for 10 checks in a row.
2019-01-16T12:57:51.302+0000 W NETWORK  [js] Unable to reach primary for set Cluster0-shard-0
2019-01-16T12:57:51.302+0000 I NETWORK  [js] Cannot reach any nodes for set Cluster0-shard-0. Please check network connectivity and the status of the set. This has happened for 11 checks in a row.
2019-01-16T12:57:51.305+0000 E QUERY    [js] Error: connect failed to replica set Cluster0-shard-0/cluster0-shard-00-00-jxeqq.mongodb.net:27017,cluster0-shard-00-01-jxeqq.mongodb.net:27017,cluster0-shard-00-02-jxeqq.mongodb.net:27017 :
connect@src/mongo/shell/mongo.js:328:13
@(connect):1:6
exception: connect failed

It doesn’t seem to be a network issue as I can connect through Compass. I get the same error in Powershell and CMD

Hi Jacques_52247,

Your command for the connection is right. As also suggested by the error, please check your network and try again.
If again it doesn’t help, try to ping the cluster and see if you can connect to cluster:

 ping cluster0-shard-00-00-jxeqq.mongodb.net

If you are unable to connect, try using different machine or contact your IT office.

Kanika