Cannot connect to atlas using Mongosh

I am using mongosh.

Trying to connect to the tutorial database using windows powershell with the following command:

mongosh “mongodb+srv://sandbox.rmjaa.mongodb.net/sample_training” --username m0001

After entering the password, this is what I keep getting:

Connecting to: mongodb+srv://sandbox.rmjaa.mongodb.net/admin?appName=mongosh+1.1.9
Error: queryTxt ETIMEOUT sandbox.rmjaa.mongodb.net

Please help

Hi @Ma_Ek,

Welcome to the community :slightly_smiling_face:,

After entering the password, this is what I keep getting:
Connecting to: mongodb+srv://sandbox.rmjaa.mongodb.net/admin?appName=mongosh+1.1.9
Error: queryTxt ETIMEOUT sandbox.rmjaa.mongodb.net

The most likely cause of the error is a DNS timeout resolving the TXT record.

Could you advise the output of the following command(s) from the client which you are receiving the error?:

dig txt sandbox.rmjaa.mongodb.net

OR

nslookup -type=txt sandbox.rmjaa.mongodb.net

As a temporary workaround and to also assist with narrowing down what the issue is, you can attempt to connect using the standard connection string format which includes the authSource and replicaSet name that are generally returned upon resolving the TXT records. An example of how to obtain this can be found here on this post although you’ll need to select connection via mongo shell rather than the node.js driver.

Additionally, please ensure the IP of the client that’s attempting to connect via mongosh is on the Network Access List. You may also find the troubleshoot connection issues documentation and the following blog post useful.

Regards,
Jason

2 Likes

Thank you @Jason_Tran

This is the output of nslookup

nslookup -type=txt sandbox.rmjaa.mongodb.net
Server: dlinkrouter
Address: 192.168.0.1

DNS request timed out.
timeout was 2 seconds.
DNS request timed out.
timeout was 2 seconds.
*** Request to dlinkrouter timed-out

An example of how to obtain this can be found here on this post although you’ll need to select connection via mongo shell rather than the node.js driver.

Upon selecting mongosh option, I get the same url (it has no mention of authSource and replicaSet)

Have you allowed acces from anywhere?
Authsource and replicaset you will find in standard string available in mongo shell version

Hi @Ma_Ek,

Server: dlinkrouter
Address: 192.168.0.1
DNS request timed out.
timeout was 2 seconds.
DNS request timed out.
timeout was 2 seconds.
*** Request to dlinkrouter timed-out

The server ‘dlinkrouter’ (the current DNS you’re using) appears to be failing to resolve the TXT record. You can perhaps try using 8.8.8.8 for testing purposes and see if you can connect again. After trying another DNS like 8.8.8.8, please provide any errors received after connecting or advise if that has helped.

With regards to the mongosh connect options, from the menu shown in your screenshot, please select on the drop down list where it states “Select your mongo shell version” and choose the earliest version available which should be “3.4 or earlier”:
image

Hope this helps.

Jason

This router is behind the WAN of the local fibre provider. As such, everything else has worked in the past wrt Azure/AWS hosted sql databases. I don’t know why it can’t connect to Atlas. Since it is connected via WAN, I can’t change the DNS.

If I select 3.4 or earlier, it gives a command with “mongo” instead of “mongosh”. Windows Powershell does not recognise “mongo”.

mongo --version
mongo : The term ‘mongo’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify
that the path is correct and try again.
At line:1 char:1

  • mongo --version
  •   + CategoryInfo          : ObjectNotFound: (mongo:String) [], CommandNotFoundException
      + FullyQualifiedErrorId : CommandNotFoundException

This is the current network access list

Hi @Ma_Ek,

Run the command to connect using the 3.4 URI but replace ‘mongo’ with ‘mongosh’.

Please advise of the output after attempting this.

Regards
Jason

This worked! Thanks
Whom to write to get all these things updated?

1 Like

Glad to hear it worked.

Whom to write to get all these things updated?

I believe the initial use of the DNS seed list format (mongodb+srv connection string) failed due to a DNS resolution issue. From my end I am able to resolve the TXT record:

nslookup -type=txt sandbox.rmjaa.mongodb.net
Server:		2403:5806:e02:0:449c:f1ff:fea8:487f
Address:	2403:5806:e02:0:449c:f1ff:fea8:487f#53

Non-authoritative answer:
sandbox.rmjaa.mongodb.net	text = "authSource=admin&replicaSet=atlas-10ykv6-shard-0"

Apparently the authSource and replicaSet values are returned in comparison to the DNS used in your previous post which had timed out:

nslookup -type=txt sandbox.rmjaa.mongodb.net
Server: dlinkrouter
Address: 192.168.0.1

DNS request timed out.
timeout was 2 seconds.

Hence I believe that Atlas connectivity is not the issue in this case, but rather it’s a DNS resolution issue from the client you’re using specifically. The DNS server that you’re connecting to doesn’t seem to be responding to your requests (thus the timed out message). It may be that the server doesn’t support TXT records, since you’re able to successfully connect using a different URI that doesn’t involve a TXT record.

Regards,
Jason

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.