Cloud Run errors connecting to Cloud MemoryStore (REDIS Basic) using NEST JS REDIS library

Below are the errors from CR service and also a detailed description of the setup.

Screenshot 2024-03-18 at 12.17.46 PM.png

Note:- Cloud Run and REDIS instance are co-located in the same region

Cloud Run Configuration

  1. Using 2nd Gen with 1MiB RAM and 2vCPU
  2. Using Direct VPC Egress in Preview (Not serverless VPC Connector)
  3. CPU Always allocated

REDIS Configuration

  1. Cloud Memory Store REDIS basic instance (not REDIS cluster)
  2. Redis Version:- 7
  3. Connection Type:- Direct Peering

REDIS Client / App Code

1. Using NEST  JS REDIS library 

 

 

1 2 121
2 REPLIES 2

Hello @dheerajpanyam ,

Welcome to Google Cloud Community!

The error message you're encountering, "Unhandled error event: Error: getaddrinfo ENOTFOUND redis," suggests that the DNS name "redis" cannot be resolved. This indicates a possible misconfiguration.

Here are some troubleshooting steps to consider:
1. Ensure your NestJS Redis library's host configuration matches either the private IP address or the hostname of your Redis instance in Cloud Memory Store. Using a generic hostname like "redis" may lead to DNS resolution issues if it isn't correctly mapped to your Redis instance's IP address, or if there isn't a corresponding DNS entry within your VPC network.
2. Considering you're using Direct VPC Egress rather than a Serverless VPC Connector, make sure your Cloud Run service's VPC egress is configured correctly to communicate with Google Cloud services, such as Cloud Memory Store. Note that Direct VPC Egress is currently in Preview, so there might be limitations or issues that are not fully documented yet.
3. Check  that your Cloud Run service and Redis instance have compatible network security configurations to allow traffic between them. This includes checking for any firewall rules that might block traffic between your Cloud Run instances and the Redis instance.

Should these steps not resolve the issue, consider contacting Google Cloud support for further assistance.

Thanks @juliadeanne Let me troubleshoot by following your steps.