I have set up a private endpoint to connect from my AWS EC2 instance. The endpoint is created successfully and the status is active on Mongo Atlas as well on AWS. I have followed this instruction guide step by step, but still I am unable to connect to the database from my instance.
When I ping the host name from ec2 I get no response.
Following is the error when I try to connect to the cluster.
[ec2-user@ip-10-0-0-XXXX etc]$ mongo "mongodb+srv://<username>:<password>@field-pl-0.XXXX.mongodb.net/test"
MongoDB shell version v5.0.6
connecting to: mongodb://pl-0-us-west-2.XXXX.mongodb.net:XXXX,
pl-0-us-west-2.XXXX.mongodb.net:XXXX,
pl-0-us-west-2.XXXX.mongodb.net:X/test/test?
authSource=admin&compressors=disabled&
gssapiServiceName=mongodb&replicaSet=Field-shard-0&ssl=true
{"t":{"$date":"2022-04-11T18:29:10.086Z"},"s":"I", "c":"NETWORK",
"id":XXXX, "ctx":"ReplicaSetMonitor-TaskExecutor","msg":"RSM host selection timeout",
"attr":{"replicaSet":"Field-shard-0","error":"FailedToSatisfyReadPreference:
Could not find host matching read preference { mode: \"nearest\" } for set Field-shard-0"}}
*** You have failed to connect to a MongoDB Atlas cluster.
Please ensure that your IP allowlist allows connections from your network.
Error: Could not find host matching read preference { mode: "nearest" } for set Field-shard-0,
Field-shard-0/pl-0-us-west-2.XXXX.mongodb.net:XXXX,pl-0-us-west-2.XXXX.mongodb.net:XXXX,
pl-0-us-west-2.XXXX.mongodb.net:XXXX :
connect@src/mongo/shell/mongo.js:372:17
@(connect):2:6
exception: connect failed
exiting with code 1
Is there anything I’m missing? Any help is much appreciated, thank you!