We have a Google Cloud Function that tries to connect to a Redis server that sits on a Compute Engine instance. The Compute Engine Redis port is open and can connect to the Redis server from our local machines. Nonetheless, when the Cloud Function tries to do so, it gets the following error:
Redis connection to 35.xxx.xx.xx:6379 failed - connect ETIMEDOUT 35.xxx.xx.xx:6379 at Object.exports._errnoException (util.js:1020:11) at exports._exceptionWithHostPort (util.js:1043:20) at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1105:14) code: 'ETIMEDOUT', errno: 'ETIMEDOUT', syscall: 'connect', address: '35.xxx.xx.xx', port: 6379 }
We are using the redis npm package (Redis Node Client) to connect which again works from our local machines.
We pass the IP of the EC server to the host value and the authentication secret to the password value. Again this seems to work locally.
Any ideas?
After all, it was indeed a firewall issue. We didn't have the correct service account setup.
One needs to visit the firewall rules config page and add the appropriate Source Filter (or Second source filter) to type Service Account and add the service account of the Cloud Functions.