Reputation: 79
I have deployed a Redis instance using GCP Memorystore. I also have a django app deployed using App Engine. However, I am facing problems connecting these 2. Both are deployed in the same timezone. The package that I'm using is django_redis. When I try to login to admin page I face a connection error. The error is:
Exception Value: Error 110 connecting to <Redis instance IP>:6379. Connection timed out.
Exception Location: /env/lib/python3.7/site-packages/redis/connection.py in connect, line 557
In settings.py I use:
CHANNEL_LAYERS = {
"default": {
"BACKEND": "channels_redis.core.RedisChannelLayer",
"CONFIG": {
"hosts": [("<Redis instance IP>", 6379)],
},
},
}
CACHES = {
"default": {
"BACKEND": "django_redis.cache.RedisCache",
"LOCATION": 'redis://<Redis instance IP>/0',
"OPTIONS": {
"CLIENT_CLASS": "django_redis.client.DefaultClient"
}
}
}
Note: With locally installed Redis and set to localhost, everything works fine.
Upvotes: 1
Views: 885
Reputation: 9359
In order to connect to Memorystore, you have to set up a VPC Network for your application, and add that connection into app.yaml
into property vpc_access_connector
. It's described here in docs: Connecting to a VPC network
Upvotes: 1