Secure Connection Issue with MongoDB Atlas PrivateLink in Amplify App (Next.js)

Hi everyone,

I’m working on a small e-commerce application using Next.js deployed through Amplify. I’m trying to establish a secure connection between my MongoDB Atlas database and the app using PrivateLink.

I followed the guide on the AWS website (Connecting Applications Securely to a MongoDB Atlas Data Plane with AWS PrivateLink | AWS Partner Network (APN) Blog) to set up PrivateLink and successfully created the endpoint. I can also generate the private connection URL for the Mongo driver.

However, when I replace the standard connection URL in my environment variables with the private URL, the app fails to connect. It functions perfectly with the standard URL.

Unfortunately, I’m not seeing any specific error messages in the logs (Mongodb timeouts). I’ve double-checked the environment variable values and verified network connectivity, but the issue persists.

Could someone please advise on how to troubleshoot this further or what configuration details I might be missing?
My current workaround is to use the standard url and whitelist all ips but this seems like a security concern.

Thanks in advance!