AWS Private Endpoint not working

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>"
MongoDB shell version v5.0.6
connecting to: mongodb://,,
{"t":{"$date":"2022-04-11T18:29:10.086Z"},"s":"I",  "c":"NETWORK",  
"id":XXXX, "ctx":"ReplicaSetMonitor-TaskExecutor","msg":"RSM host selection timeout",
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/,, :
exception: connect failed
exiting with code 1

Is there anything I’m missing? Any help is much appreciated, thank you!

This is resolved. I had to add a security group with inbound rules to the AWS PrivateLink that allow traffic from my ec2 instances.

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.