MongoDB Atlas SQL Tableau JDBC Error when connecting

Hello, I have been having trouble connecting from my Tableau Server hosted on AWS EC2 to a test federated database on MongoDB atlas and cant figure out the issue.

Here is the error i am getting:

I have replaced the connection string and db name with placeholders but I can confirm that they are correct. Here’s part of the connection string: mongodb:///<db_name>?ssl=true&authSource=admin&connectTimeoutMS=30000

My Tableau Server (v2023.1.8) is a trial version hosted on AWS EC2 (Amazon Linux 2) with only ports 22, 80, 443 and 27017 being allowed via AWS security group.

I’m using MongoDB JDBC Driver v2.1.0 and MongoDB JDBC Connector v1.2.0.

I have tried the same in Tableau Desktop (v2023.1) and I am able to connect to MongoDb Atlas with the same URI and credentials.

I’m not sure if this is due to a port issue but any help with this will be greatly appreciated!

Managed to troubleshoot the issue after looking at the VPC flow logs. I just had to allow inbound traffic for ephemeral ports for the NACL of public subnet my EC2 instance was in.

Reason for this is because NACLs are stateless and information about any outbound packets are not saved. So, whenever a response to connect from MongoDB Atlas comes in, the NACL rule blocks the response if inbound traffic for ephemeral ports are not allowed. Note we do NOT have to do the same for security groups as they are stateful.