skip to Main Content

I’ve Redis chace installed on both my local and aws elasticache. My Django project runs well on my local machine with Redis. However, when I connect to my redis remotely on aws, I get the following error.

Error 10060 connecting to xyz.0001.use2.cache.amazonaws.com:6379. A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

I have the following Django settings for the local redis:

CACHES = {
    'default': {
        'BACKEND': 'django_redis.cache.RedisCache',
        'LOCATION': 'redis://127.0.0.1:6379/1',
        'OPTIONS': {
            'CLIENT_CLASS': 'django_redis.client.DefaultClient',
        }
    }
}

And this the Django settings for the remote redis instance:

CACHES = {
    'default': {
        'BACKEND': 'django_redis.cache.RedisCache',
        'LOCATION': 'redis://xyz.0001.use2.cache.amazonaws.com:6379',
        'OPTIONS': {
            'CLIENT_CLASS': 'django_redis.client.DefaultClient',
        }
    }
}

Again, when I switch from local to remote caches settings, I get that error above.

I know that I it is not possible to connect ElastiCache outside AWS unless you have a vpn connection. So, I’ve set up the vpn client end point on aws and connected to it using the aws vpn client. I can successfully connect via vpn as shown below.

enter image description here

Also, if I run the following command under C:Program FilesRedis on my command prompt window

redis-cli -h magicstat-redis.ysw0xy.0001.use2.cache.amazonaws.com -p 6379 ping

I get this error.
enter image description here

Any idea why I still can’t connect from my local machine to the remote redis on aws elasticache even though I can connect via vpn?

2

Answers


  1. Chosen as BEST ANSWER

    I've finally found out what was going on. As you can see from the screenshot below, I've added the custom 0.0.0.0/0 source. I can connect via VPN now.

    enter image description here


  2. Sadly you can’t connect from your local machine. Elasticache is a service designed to be used internally to your VPC. External access is discouraged due to the latency of Internet traffic and security concerns.

    Please refer this documentation : https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/accessing-elasticache.html#access-from-outside-aws

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search