Can Load SandBox Into Compass, But Not Mongo Shell

Hi there,

I can connect to my MongoDB Sandbox within Compass, but not within the MongoDB Shell.

When I try the shell, I get
2018-10-17T10:45:04.489-0300 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.

I am using:

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

Any idea why I could connect with compass and not shell?

Hi JustLearningMongoDB,

I just tried (though I replaced the double quotes as it was showing as special character), but I was able to connect. I am using this command:

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

Just try and replace the double quotes surrounding the host address in the terminal only.

Let me know if it still don’t work!

Kanika

1 Like

I’ve tried again, using the one you used and still nothing. I then went in and replaced the quotes to make sure they are not odd (changed from copy/paste). I still have the same error.

EDIT: If it helps, I cannot connect to the Class Cluster either with MongoDB Shell. But, like my sandbox it will load in Compass.

Hi,

  • Try ping cluster0-shard-00-00-xbbbx.mongodb.net:27017. Check if you are able to connect.
  • Which version of Mongo are you using? Type mongo --version from your command line and let me know.
  • Please copy/paste exact command you are seeing
  • And do share a screenshot

Thanks, Kanika

When I try to ping, I get:

Ping request could not find host cluster0-shard-00-00-xbbbx.mongodb.net:27017. Please check the name and try again.

if I try without the port:

C:>ping cluster0-shard-00-00-xbbbx.mongodb.net

Pinging ec2-35-168-141-209.compute-1.amazonaws.com [35.168.141.209] with 32 bytes of data:
Request timed out.

Here is my mongo version print-out:

C:>mongo --version
MongoDB shell version v4.0.3
git version: 7ea530946fa7880364d88c8d8b6026bbc9ffa48c
allocator: tcmalloc
modules: enterprise
build environment:
…distmod: windows-64
…distarch: x86_64
…target_arch: x86_64

Seems like your network is blocking the request.
Please check here, if you can find some answer.

Try from your home network or system.

Kanika

Hi there,

I cannot ping the endpoint, but it is working within Compass and connects fine. Does it access it over the network differently?

If I use Test-NetConnection which PortQuiz shows:

PS U:> Test-NetConnection cluster0-shard-00-00-jxeqq.mongodb.net -port 27017

ComputerName : cluster0-shard-00-00-jxeqq.mongodb.net
RemoteAddress : 34.195.121.130
RemotePort : 27017
InterfaceAlias : Ethernet
SourceAddress : *********
TcpTestSucceeded : True

So it looks like I should have access.

Hi @JustLearningMongoDB,

Not really sure why you are not able to connect using the mongo shell given that you can connect using Compass, and that you’ve verified that the servers are reachable from your end.

I cannot reproduce this issue, I can reach the cluster correctly.

Can you, as @Kanika suggested, try to connect from a different network/pc combination?

N.

Hi there,

I"m getting a warning like "shell & server versions do no match’

Hi Akhil_27227,

This is just a warning, you can continue with the Course and mongo shell.

For the explanation of Warning:

shell & server versions do no match

It means the version of your system i,e 4.0.3 (I am assuming) and the server version (to which you are connecting i.e cluster0-shard-00-00-jxeqq.mongodb.net is using different version i.e 3.6.8

However, you may have noticed that when you connected using mongo --nodb it is showing MongoDB shell version v4.0.3 which match your shell version, so it is not throwing any warning

I hope it clears the confusion!

Thanks, Kanika

Thanks for the reply Kanika !!!

My query is clarified…

1 Like

Hi @Norberto,

I have not had a chance to try another network configuration, however I did have support take a look. They have verified the connection is outgoing fine and it would appear the issue is on the Hosting side.

Do you have any recommendations on what I could try, in order to figure out what is blocking me?

Hi JustLearningMongoDB,

I think you are already in the mongo shell when you are attempting to connect to our or your sandbox cluster. Can you please try after exiting your current mongo shell? And if that also doesn’t work, just paste the whole command as it is and the screenshot of the whole terminal screen.

Make sure you replace the double quotes. :slight_smile:

Kanika

Hi @Kanika
Here is my output from command prompt. Just to be safe, after pasting it I went in and wrote over the double quotes. Please let me know if you see anything wrong here:

I am also facing the same issue. Is it due to the version 4.0?When we attempt to connect with Sandbox , why it shows MongoDB Enterprise Cluster 0 ?

Hi @Joseph_89514 / @JustLearningMongoDB,

This error you are experiencing is related with the .dbshell file that keeps a history of your successful shell commands. The reason why it is not able to load it or open it may have to do with your permissions on your home folder, which is rather unusual.

Let’s try two different approaches here:

1 - Manually create a file, in your home directory called .dbshell
2 - Connect to your sandbox cluster appending the command line option --norc

In step 1) if you are not able to create the file, this means you do not have write permissions in your home directory. You may want to check why that is.

Step 2) will override the need to create the file but may give you an error loading the .dbshell file. This should not stop you from connecting to the server.

Let us know how it goes.

N.

1 Like

Hi @Norberto

Thanks for the suggestion. Here are the results:
I already had the .dbshell file so I removed it and created it again. Same issue.
I then tried the --norc option and got the same result.

I tried another computer and network which had zero issues. Ideally we would get my main machine on its current network running. Please let me know what else I may try.

Hello,

I am also getting similar issue.

I am able to connect through compass but my request through shell times out.

I am able to ping the servers without any issues from my network.

I error I am getting is related to SSL cetificate it seem.

Kindly suggest how can i connect from shell.

If you are getting TLS certificate errors, then you are NOT experiencing time outs. If you got the certificate, it means that your shell managed to connect to the port.

Could you show us the error message?

Hi,
I am having the opposite problem were I can connect via the shell but can’t via Compass. Could you help please.