MongoDB connection string causing issue

The fact that you have {myHost} verbatim in the error message, rather that have a real host name such as localhost,

makes me think that you are missing some configuration. Things like the curly braces indicate place holders that you have to fill with real values.

However, your OP shows otherwise:

But the above address is a cluster and would usually caused another type of DNS error because the address is not an host.

Your code

specifies the use of an host. If you connect to a cluster like your OP hints at, you must use mongodb+srv:// rather than mongodb://.

The differences between the 2 are explained in the link you shared in the OP.

1 Like