Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Cloud run service is unable to connect to MongodbAtlas after whitelisting nat-auto-ip-xxxxxx config

I am trying to connect to Serverless Mongodb from a service in GCP cloud run. Right now  connection is only successful if I allow all IP(0..0.0.0).

I followed Serverless VPC access + NAT creation @ https://cloud.google.com/run/docs/configuring/static-outbound-ip and few other online resources. The external IP in nat config is not allowed to connect by Mongodb even after whitelisting it.

Am I missing anything?

Thanks in advance.

0 1 686
1 REPLY 1

Hi,

With very limited information it is very hard to pinpoint what is causing this concern. However I would like to suggest enabling Firewall Logs[1] when creating a Firewall Rule using 0.0.0.0/0 and also the external IP in your NAT config.

After that, test the connection, be mindful of the error message then check the logs[2]. From the logs you will see what might be causing the issue.

[1]https://cloud.google.com/firewall/docs/using-firewall-rules-logging?_ga=2.130981004.-247269382.16944...
[2]https://cloud.google.com/firewall/docs/using-firewall-rules-logging?_ga=2.130981004.-247269382.16944...