Connecting string for M2

What is the connecting string Atlas M2 cluster
I’m using the following, Is it OK?


Sometimes have the following exceptions-
SocketException: Software caused connection abort (OS Error: Software caused connection abort, errno = 103), address =, port = 42848

 ConnectionException: connection closed: The socket connection has been reset by peer.
Possible causes:
- Trying to connect to an ssl/tls encrypted database without specifiyng
  either the query parm tls=true or the secure=true parameter in
- The server requires a key certificate from the client, but no certificate has been sent
- Others

The conect string is not as per SRV format
You can get it from your Atlas account
It should not have individual hostnames and replicaset name.Looks like you mixed both SRV & long form of strings

When I use the recommended string from atlas I have exception

The string -

The exception -
MongoDB ConnectionException: Could not connect to
SocketException: Failed host lookup: ‘’ (OS Error: No address associated with hostname, errno = 7)

A few things.

I am surprised that you get the error No address associated with hostname as this error would indicate that you are missing +srv in your connection string. A cluster has no host name address it has a seed list record which is different and generates a different error message.

Hiding your real cluster name does not help us helping you.

Hiding your cluster name relies on security through obscurity. Appropriate network setup and user access is a better way.

Here is the connection string
const uri = “mongodb+srv://”;

The cluster DNS is correct as seen below.

id 23124
opcode QUERY
flags QR RD RA
;ANSWER 60 IN TXT "authSource=admin&replicaSet=atlas-7g2b5k-shard-0"

There are however some inconsistencies with what you posted earlier.

You specified

but the real replica set name is atlas-7g2b5k-shard-0. How did you get the razveo name?

Basically, the following should work with the appropriate user name and password.

If it still does not work, verify that

  1. you allow connections from your public IP in network security
  2. that your firewall, isp or vpn allows outgoing connection via port 27017

I just updated the replica as your suggestion in my long format . and its working
The short format didn’t work
Is it possible that I need to add parameters for the cluster?
Now I will see if have more exceptions

1 Like