Connect failed to the class Atlas cluster

hi,
i have problem while connecting to the class Atlas cluster.
when i run it in cmd , i get the rror:
exception:connect failed.
any ideas why? by the way i have instaled enterprice edition corectly
C:\Users\nzedginidze>mongo
MongoDB shell version v4.2.0
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
2019-10-11T13:11:52.964+0400 E QUERY [js] Error: couldn’t connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: No connection could be made because the target machine actively refused it. :

Hi @Nana_08979,

For connecting to the class atlas cluster please run the command mentioned below in your cmd/terminal.

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

Note : Please make sure you are running this out of the mongo shell, otherwise it will throw an error.

Here, you have run the mongo command which will connect you to the mongod instance running on the default port 27017 and not the class atlas cluster.

I believe the reason why you are getting this error message is because the mongod instance is not running on your system. To make it work please open a new terminal/cmd window and then run the command mentioned below.

mongod

And now try to connect to it by running the mongo command in a new terminal.

Hope it helps!

If you have any other issue, please feel free to get back to us.

Happy Learning :slight_smile:

Thanks,
Shubham Ranjan
Curriculum Support Engineer

1 Like

so, when i tupe mongo:

C:\Users\nzedginidze>mongo
MongoDB shell version v4.2.0
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { “id” : UUID(“fdd0b699-c0df-49f9-afe1-628be15144a1”) }
MongoDB server version: 4.2.0
Server has startup warnings:
2019-10-11T13:26:15.025+0400 I CONTROL [initandlisten]
2019-10-11T13:26:15.025+0400 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2019-10-11T13:26:15.025+0400 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2019-10-11T13:26:15.025+0400 I CONTROL [initandlisten]
MongoDB Enterprise >
MongoDB Enterprise >

------its means i am already in mongodb enterprise , then i have to copy and paste this one?

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.

Hi @Nana_08979,

First of all good job on this one. :clap:

Yes, now you are inside the mongo shell and connected to a mongod instance running on your local machine.

If you want to connect to the class atlas cluster then please exit out of the mongo shell by running the exit command.

exit

Once you are outside the mongo shell then please run this command in the command prompt for connecting to the class atlas cluster.

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

Hope it helps!

If you have any other issue, please feel free to get back to us.

Happy Learning :slight_smile:

Thanks,
Shubham Ranjan
Curriculum Support Engineer

MongoDB Enterprise >
MongoDB Enterprise > exit
bye

C:\Users\nzedginidze>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
2019-10-11T14:01:34.917+0400 W CONTROL [main] Option: ssl is deprecated. Please use tls instead.
MongoDB shell version v4.2.0
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/test?authSource=admin&compressors=disabled&gssapiServiceName=mongodb&replicaSet=Cluster0-shard-0
2019-10-11T14:01:35.105+0400 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-10-11T14:01:35.105+0400 I CONNPOOL [ReplicaSetMonitor-TaskExecutor] Connecting to cluster0-shard-00-01-jxeqq.mongodb.net:27017
2019-10-11T14:01:35.106+0400 I CONNPOOL [ReplicaSetMonitor-TaskExecutor] Connecting to cluster0-shard-00-02-jxeqq.mongodb.net:27017
2019-10-11T14:01:35.106+0400 I CONNPOOL [ReplicaSetMonitor-TaskExecutor] Connecting to cluster0-shard-00-00-jxeqq.mongodb.net:27017


*** It looks like this is a MongoDB Atlas cluster. Please ensure that your IP whitelist allows connections from your network.

2019-10-11T14:01:53.565+0400 E QUERY [js] Error: Could not find host matching read preference { mode: “primary”, tags: [ {} ] } for set Cluster0-shard-0 :
connect@src/mongo/shell/mongo.js:341:17
@(connect):2:6
2019-10-11T14:01:53.582+0400 F - [main] exception: connect failed
2019-10-11T14:01:53.582+0400 E - [main] exiting with code 1

:sweat:

Hi @Nana_08979,

Are you on a corporate network or behind a firewall ?

If yes then please make sure you are not connected to any VPN network and firewall/antivirus is disabled .

If it does not resolve the issue then please contact your IT department to see if there is a workaround or try to make the request from another location such as your home network .

Hope it helps!

Thanks,
Shubham Ranjan
Curriculum Support Engineer