MongoDB: error parsing uri: URI with srv must not include a port number

159 views Asked by At

when using this protocol:

mongodb+srv://

I get an error if I include a port:

MongoDB: error parsing uri: URI with srv must not include a port number

is there a reason for this (why a port is not acceptable)?

1

There are 1 answers

1
Fourchette On

If you use the SRV URI connection format, you can specify only one host and no port. Otherwise, the driver or mongosh raises a parse error and does not perform DNS resolution.

Read from documentation : https://www.mongodb.com/docs/manual/reference/connection-string/#srv-connection-format