Connection Failed : Error while connectiong to Atlas Cluster from the mongo Shell

Hi
I am getting below error while trying to connect to your Class Atlas Cluster from the mongo Shell
Error : 2019-01-19T15:05:10.334+0530 E QUERY [js] Error: connect failed to replica se
t Cluster0-shard-0/cluster0-shard-00-00-jxeqq.mongodb.net:27017,cluster0-shard-0
0-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

Please help me to solve this ASAP
Thanks in advance

Here is full error

C:\Program Files\MongoDB\Server\4.0\bin>mongo “mongodb://cluster0-shard-00-00-jx
eqq.mongodb.net:27017,cluster0-shard-00-01-jxeqq.mongodb.net:27017,cluster0-shar
d-00-02-jxeqq.mongodb.net:27017/100YWeatherSmall?replicaSet=Cluster0-shard-0” –
authenticationDatabase admin --ssl --username m001-student --password m001-mongo
db-basics
MongoDB shell version v4.0.5
exception: No digits

C:\Program Files\MongoDB\Server\4.0\bin>mongo “mongodb://cluster0-shard-00-00-jx
eqq.mongodb.net:27017,cluster0-shard-00-01-jxeqq.mongodb.net:27017,cluster0-shar
d-00-02-jxeqq.mongodb.net:27017/test?replicaSet=Cluster0-shard-0” --authenticati
onDatabase 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-s
hard-00-01-jxeqq.mongodb.net:27017,cluster0-shard-00-02-jxeqq.mongodb.net:27017/
test?authSource=admin&gssapiServiceName=mongodb&replicaSet=Cluster0-shard-0
2019-01-19T17:21:24.282+0530 I NETWORK [js] Starting new replica set monitor fo
r Cluster0-shard-0/cluster0-shard-00-00-jxeqq.mongodb.net:27017,cluster0-shard-0
0-01-jxeqq.mongodb.net:27017,cluster0-shard-00-02-jxeqq.mongodb.net:27017
2019-01-19T17:21:25.789+0530 W NETWORK [ReplicaSetMonitor-TaskExecutor] Unable
to reach primary for set Cluster0-shard-0
2019-01-19T17:21:25.790+0530 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-19T17:21:28.451+0530 I NETWORK [js] Successfully connected to cluster0-
shard-00-01-jxeqq.mongodb.net:27017 (1 connections now open to cluster0-shard-00
-01-jxeqq.mongodb.net:27017 with a 5 second timeout)
2019-01-19T17:21:29.239+0530 I NETWORK [js] Marking host cluster0-shard-00-01-j
xeqq.mongodb.net:27017 as failed :: caused by :: Location40659: can’t connect to
new replica set master [cluster0-shard-00-01-jxeqq.mongodb.net:27017], err: cou
ldn’t connect to server cluster0-shard-00-01-jxeqq.mongodb.net:27017, connection
attempt failed: SSLHandshakeFailed: QueryContextAttributes for connection info
failed with-2146893055
2019-01-19T17:21:32.152+0530 I NETWORK [js] Marking host cluster0-shard-00-01-j
xeqq.mongodb.net:27017 as failed :: caused by :: Location40659: can’t connect to
new replica set master [cluster0-shard-00-01-jxeqq.mongodb.net:27017], err: cou
ldn’t connect to server cluster0-shard-00-01-jxeqq.mongodb.net:27017, connection
attempt failed: SSLHandshakeFailed: QueryContextAttributes for connection info
failed with-2146893055
2019-01-19T17:21:35.151+0530 I NETWORK [js] Marking host cluster0-shard-00-01-j
xeqq.mongodb.net:27017 as failed :: caused by :: Location40659: can’t connect to
new replica set master [cluster0-shard-00-01-jxeqq.mongodb.net:27017], err: cou
ldn’t connect to server cluster0-shard-00-01-jxeqq.mongodb.net:27017, connection
attempt failed: SSLHandshakeFailed: QueryContextAttributes for connection info
failed with-2146893055
2019-01-19T17:21:38.797+0530 I NETWORK [js] Marking host cluster0-shard-00-01-j
xeqq.mongodb.net:27017 as failed :: caused by :: Location40659: can’t connect to
new replica set master [cluster0-shard-00-01-jxeqq.mongodb.net:27017], err: cou
ldn’t connect to server cluster0-shard-00-01-jxeqq.mongodb.net:27017, connection
attempt failed: SSLHandshakeFailed: QueryContextAttributes for connection info
failed with-2146893055
2019-01-19T17:21:38.798+0530 E QUERY [js] Error: can’t authenticate against r
eplica set node cluster0-shard-00-01-jxeqq.mongodb.net:27017 :: caused by :: can
't connect to new replica set master [cluster0-shard-00-01-jxeqq.mongodb.net:270
17], err: couldn’t connect to server cluster0-shard-00-01-jxeqq.mongodb.net:2701
7, connection attempt failed: SSLHandshakeFailed: QueryContextAttributes for con
nection info failed with-2146893055 :
connect@src/mongo/shell/mongo.js:328:13
@(connect):1:6
exception: connect failed

Try with 3.6+ Shell code.

Thanks for your reply

Yes I already have 4.0 cell

Still I have same problem

Thats good, but are you using the command for 3.6+ shell which is displayed.

I am having the same issue. I am using version 3.6.3. Is there any way I can upgrade my shell?

Hello Costas, you are on latest version of Shell. what is the error you got?

I am using cmd of window
Do I need to download shell prompt?

I am using Linux Mint.
When trying to connect to my server I was prompted with a message saying that port is closed. Both the compass and the shell displayed errors. I decided to uninstall mongo shell and reinstall the latest 4.1 version. Yet everytime I try to purge mongodb-enterprise-serve I get this error:

installArchives() failed: (Reading database …
(Reading database … 5%%
(Reading database … 10%%
(Reading database … 15%%
(Reading database … 20%%
(Reading database … 25%%
(Reading database … 30%%
(Reading database … 35%%
(Reading database … 40%%
(Reading database … 45%%
(Reading database … 50%%
(Reading database … 55%%
(Reading database … 60%%
(Reading database … 65%%
(Reading database … 70%%
(Reading database … 75%%
(Reading database … 80%%
(Reading database … 85%%
(Reading database … 90%%
(Reading database … 95%%
(Reading database … 100%%
(Reading database … 295333 files and directories currently installed.)
Removing mongodb-enterprise-server (4.0.5) …
Failed to stop mongod.service: Unit mongod.service not loaded.
invoke-rc.d: initscript mongod, action “stop” failed.
dpkg: error processing package mongodb-enterprise-server (–remove):
installed mongodb-enterprise-server package pre-removal script subprocess returned error exit status 5
Errors were encountered while processing:
mongodb-enterprise-server

if you in Windows OS cmd is best… no need to use any shell. just use the Short SRC Connection string(Shell 3.6+)…

it looks like

mongo “mongodb+srv://cluster9-ng0yw.mongodb.net/test” --username

cluster9 is my named cluster in sandbox.

please put in the command lines you were using? seems like you have not stopped the “mongod”.

The error I posted was returned when trying to uninstall the mongodb-enterprise-server using the Software Manager of Linux Mint. When running sudo apt purge mongodb-enterprise-server I get this error:

Reading package lists… Done
Building dependency tree
Reading state information… Done
The following package was automatically installed and is no longer required:
snmp
Use ‘sudo apt autoremove’ to remove it.
The following packages will be REMOVED:
mongodb-enterprise-server*
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
After this operation, 63,4 MB disk space will be freed.
Do you want to continue? [Y/n] Y
(Reading database … 295333 files and directories currently installed.)
Removing mongodb-enterprise-server (4.0.5) …
Failed to stop mongod.service: Unit mongod.service not loaded.
invoke-rc.d: initscript mongod, action “stop” failed.
dpkg: error processing package mongodb-enterprise-server (–remove):
installed mongodb-enterprise-server package pre-removal script subprocess returned error exit status 5
Errors were encountered while processing:
mongodb-enterprise-server
E: Sub-process /usr/bin/dpkg returned an error code (1)

When running sudo apt install mongodb-clients I get a similar error.

I managed to solve that issue, but I still have mongo version 3.6.3.
Whenever I use compass to connect to my SANDBOX cluster I get this error:

connection 5 to sandbox-shard-00-00-ycp9k.mongodb.net:27017 closed

I am still facting same issue even with
mongo “mongodb+srv://cluster0-w4sdb.mongodb.net/test” --username m001-student
Please can you help me how to solve this problem?

Hi Manish,

I am able to connect to Mongo shell using this command:

 mongo "mongodb+srv://cluster0-w4sdb.mongodb.net/test" --username m001-student

It will ask for password and you need to enter the password and press Enter/Return. Let me know if you face any error, check for firewall issues.

Kanika

C:\Users\manish>mongo “mongodb+srv://mflix-ak1gt.mongodb.net/test” --username m2
20student
MongoDB shell version v4.0.5
Enter password:
connecting to: mongodb://mflix-shard-00-01-ak1gt.mongodb.net.:27017,mflix-shard-
00-02-ak1gt.mongodb.net.:27017,mflix-shard-00-00-ak1gt.mongodb.net.:27017/test?a
uthSource=admin&gssapiServiceName=mongodb&replicaSet=mflix-shard-0&ssl=true
2019-02-16T14:51:05.386+0530 I NETWORK [js] Starting new replica set monitor fo
r mflix-shard-0/mflix-shard-00-01-ak1gt.mongodb.net.:27017,mflix-shard-00-02-ak1
gt.mongodb.net.:27017,mflix-shard-00-00-ak1gt.mongodb.net.:27017
2019-02-16T14:51:06.827+0530 W NETWORK [ReplicaSetMonitor-TaskExecutor] Unable
to reach primary for set mflix-shard-0
2019-02-16T14:51:06.829+0530 I NETWORK [ReplicaSetMonitor-TaskExecutor] Cannot
reach any nodes for set mflix-shard-0. Please check network connectivity and the
status of the set. This has happened for 1 checks in a row.
2019-02-16T14:51:09.389+0530 W NETWORK [js] Unable to reach primary for set mfl
ix-shard-0
2019-02-16T14:51:09.389+0530 I NETWORK [js] Cannot reach any nodes for set mfli
x-shard-0. Please check network connectivity and the status of the set. This has
happened for 2 checks in a row.
2019-02-16T14:51:12.266+0530 W NETWORK [js] Unable to reach primary for set mfl
ix-shard-0
2019-02-16T14:51:12.267+0530 I NETWORK [js] Cannot reach any nodes for set mfli
x-shard-0. Please check network connectivity and the status of the set. This has
happened for 3 checks in a row.
2019-02-16T14:51:14.865+0530 W NETWORK [js] Unable to reach primary for set mfl
ix-shard-0
2019-02-16T14:51:14.866+0530 I NETWORK [js] Cannot reach any nodes for set mfli
x-shard-0. Please check network connectivity and the status of the set. This has
happened for 4 checks in a row.
2019-02-16T14:51:17.725+0530 W NETWORK [js] Unable to reach primary for set mfl
ix-shard-0
2019-02-16T14:51:17.725+0530 I NETWORK [js] Cannot reach any nodes for set mfli
x-shard-0. Please check network connectivity and the status of the set. This has
happened for 5 checks in a row.
2019-02-16T14:51:19.628+0530 I NETWORK [js] Successfully connected to mflix-sha
rd-00-00-ak1gt.mongodb.net.:27017 (1 connections now open to mflix-shard-00-00-a
k1gt.mongodb.net.:27017 with a 5 second timeout)
2019-02-16T14:51:23.505+0530 W NETWORK [js] Unable to reach primary for set mfl
ix-shard-0
2019-02-16T14:51:24.427+0530 I NETWORK [js] Marking host mflix-shard-00-00-ak1g
t.mongodb.net.:27017 as failed :: caused by :: SocketException: can’t authentica
te against replica set node mflix-shard-00-00-ak1gt.mongodb.net.:27017 :: caused
by :: socket exception [CONNECT_ERROR] server [mflix-shard-00-00-ak1gt.mongodb.
net.:27017] connection pool error: network error while attempting to run command
‘isMaster’ on host ‘mflix-shard-00-00-ak1gt.mongodb.net.:27017’
2019-02-16T14:51:28.598+0530 W NETWORK [js] Unable to reach primary for set mfl
ix-shard-0
2019-02-16T14:51:29.229+0530 I NETWORK [js] Marking host mflix-shard-00-00-ak1g
t.mongodb.net.:27017 as failed :: caused by :: SocketException: can’t authentica
te against replica set node mflix-shard-00-00-ak1gt.mongodb.net.:27017 :: caused
by :: socket exception [CONNECT_ERROR] server [mflix-shard-00-00-ak1gt.mongodb.
net.:27017] connection pool error: network error while attempting to run command
‘isMaster’ on host ‘mflix-shard-00-00-ak1gt.mongodb.net.:27017’
2019-02-16T14:51:33.369+0530 W NETWORK [js] Unable to reach primary for set mfl
ix-shard-0
2019-02-16T14:51:33.968+0530 I NETWORK [js] Marking host mflix-shard-00-00-ak1g
t.mongodb.net.:27017 as failed :: caused by :: SocketException: can’t authentica
te against replica set node mflix-shard-00-00-ak1gt.mongodb.net.:27017 :: caused
by :: socket exception [CONNECT_ERROR] server [mflix-shard-00-00-ak1gt.mongodb.
net.:27017] connection pool error: network error while attempting to run command
‘isMaster’ on host ‘mflix-shard-00-00-ak1gt.mongodb.net.:27017’
2019-02-16T14:51:38.322+0530 W NETWORK [ReplicaSetMonitor-TaskExecutor] Unable
to reach primary for set mflix-shard-0
2019-02-16T14:51:39.149+0530 I NETWORK [js] Marking host mflix-shard-00-00-ak1g
t.mongodb.net.:27017 as failed :: caused by :: SocketException: can’t authentica
te against replica set node mflix-shard-00-00-ak1gt.mongodb.net.:27017 :: caused
by :: socket exception [CONNECT_ERROR] server [mflix-shard-00-00-ak1gt.mongodb.
net.:27017] connection pool error: network error while attempting to run command
‘isMaster’ on host ‘mflix-shard-00-00-ak1gt.mongodb.net.:27017’
2019-02-16T14:51:39.150+0530 E QUERY [js] Error: can’t authenticate against r
eplica set node mflix-shard-00-00-ak1gt.mongodb.net.:27017 :: caused by :: socke
t exception [CONNECT_ERROR] server [mflix-shard-00-00-ak1gt.mongodb.net.:27017]
connection pool error: network error while attempting to run command ‘isMaster’
on host ‘mflix-shard-00-00-ak1gt.mongodb.net.:27017’ :
connect@src/mongo/shell/mongo.js:328:13
@(connect):1:6
exception: connect failed

I still having above problem with new mongo course : [M220J]
I am not sure what firewall issue can prevent my connection
please can you describe in details

I have solved my problem by instlling mong3.6.10
There was no any firewall issue

Thanks
Manish

Thanks for the detailed output Manish.

Can you please try again with 4.0.5 version and send me the mongod-log file text especially the end lines? That will help us debug the issue.

Kanika

getting connection failed error

Hi Bharat_60369,

The connection string that I mentioned in my previous comment was for Manish’s cluster.

Please use connect command from your own Sandbox cluster, Login to cloud.mongodb.com -> Connect -> From Mongo Shell.

If you are looking to connect to our class cluster, then use this string:

  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/100YWeatherSmall?replicaSet=Cluster0-shard-0" --authenticationDatabase admin --ssl --username m001-student --password m001-mongodb-basics

Kanika