Search code examples
node.jsdockergoogle-cloud-runobjection.js

Cloud Run deployed REST API failing on only specific endpoints


So I'm trying to deploy my NodeJS rest API on Cloud Run and for the most part it deploys successfully except a couple endpoints seem to be failing with either a 404 or 500 error. However when I run the container locally using docker run -p 8080:8080 <image> all the endpoints work. The common thing between all the failing endpoints seem to be that they are accessing the remote database using the credentials stored in the .env file.

EDIT: I think it is because the database is on a private internal ip so I'm trying to figure out what I would need to do for that


Solution

  • As mentioned by @guillaume, if your database is on a private internal network then VPC connector is necessary. You can use the Connecting from Cloud Run to Cloud SQL documentation as guide whether you stick to the private IP only or decided to use a public IP which will not require a VPC connector.