简体   繁体   中英

Not able to connect on Mongodb Atlas port

I'm using an M0 GCP instance.

I can connect to the cluster using this string:

'mongodb+srv://my_user:my_pass@my_cluster-mbsnz.gcp.mongodb.net/db?retryWrites=true&w=majority'

I'm trying to use another client where I need to pass host and port, but I can't connect.

I tried telnet to the port 27017, but for some reason I'm not able to connect directly on the port.

curl http://my_cluster-mbsnz.gcp.mongodb.net:27017
curl: (7) Failed to connect to my_cluster-mbsnz.gcp.mongodb.net port 27017: Connection timed out

or

telnet my_cluster-mbsnz.gcp.mongodb.net 27017
Trying 185.82.212.199...
^C -> After a long time waiting

What might be wrong ?

+srv urls use a DNS seed. On atlas, you can click into the cluster and you should be able to see the urls for your primary & your secondaries and use those urls to connect. You should also be able to use nslookup to get that info using part of that connection string, but it's probably simpler to just look up the urls through the UI.

https://docs.mongodb.com/manual/reference/connection-string/

In order to leverage the DNS seedlist, use a connection string prefix of mongodb+srv: rather than the standard mongodb:. The +srv indicates to the client that the hostname that follows corresponds to a DNS SRV record. The driver or mongo shell will then query the DNS for the record to determine which hosts are running the mongod instances.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM