1
votes

I've set up the peering connection between MongoDB Atlas and Googles "default" VPC and the connection is labeled as "active" on both ends.

The ip range of the vpc is whitelisted in MongoDB Atlas.

But my node hosted in google-app-engine still gets timed out when accessing the MongoDB.

I use the connection url of mongodb atlas for peered connection in the form of (notice the "-pri"):

mongodb+srv://<username>:<password>@<my-cluster>-pri.rthhs.mongodb.net/<dbname>?retryWrites=true&w=majority

Which part am i missing to establich the connection? Do i need a google vpc connector?

Thanks for any help!

2
there was a worldwide google outage which may have affected you in case you were trying in the last half hourAnupam
yeah noticed that... but i was on it for a few hours already so i recon it just added insult to injuryMaximilian Körner

2 Answers

2
votes

First of all, make sure you are running M10-Cluster or above!!! VPC-peering is not available for M0/M2/M5...

And YES you do need that connector! All "Serverless"-Services from Gcloud (like GAE in standard environment) need it.

  1. create a connector in the same region as your GAE-App following these instructions. You can find the current region of your GAE-App with gcloud app describe

  2. your app.yaml has to point to that connector like this

app.yaml

runtime: nodejs10

vpc_access_connector:
  name: projects/GCLOUD_PROJECT_ID/locations/REGION_WHERE_GAE_RUNS/connectors/NAME_YOU_ENTERED_IN_STEP_1
  1. Go to your Atlas project, navigate to Network Access and whitelist the IP-range you set for the connector in Step 1

  2. You may also need to whitelist the IP-range from Step 1 for the VPC-Network. You can do that in GCP by navigating to VPC-Network -> Firewall

If you have questions about how to setup the VPC-Peering between Atlas and Gcloud try this tutorial. They do it for Kubernetes-Engine (no connector needed). But adding my steps from above will hopefully do the trick.

1
votes

Try Cannot connect to Mongo Atlas using VPC peering from GCP cluster and MongoDB and Google Cloud Functions VPC Peering?.

First step I suggest identifying whether you have physical connectivity (and so need to fix ip whitelist) or don't have connectivity (and need to fix peering configuration).