0

I have the following script

import redis
client = redis.Redis.from_url('redis://xxx.amazonaws.com:6379')
client.ping()

This works when I run it on a throwaway EC2 instamce

However when I run it locally or on a local server I get

redis.exceptions.ConnectionError: Error 11 connecting to xxx.amazonaws.com:6379. Resource temporarily unavailable.

Is this something to do with the VPC? If so, what is the way around it?

Thanks

pee2pee
  • 3,619
  • 7
  • 52
  • 133
  • Are you able to connect from another system? Are you behind any proxy server? – Msvstl Aug 02 '22 at 15:00
  • Turns out it's to do with VPCs, networks, subnets and things way above my understanding. https://stackoverflow.com/questions/27843068/aws-redis-connect-from-outside and https://stackoverflow.com/questions/21917661/can-you-connect-to-amazon-elasti%d0%a1ache-redis-outside-of-amazon – pee2pee Aug 02 '22 at 15:07

1 Answers1

0

Elasticache Redis is a VPC only service. ie. You can only conenct to it from resources within your VPC such as an EC2 instance or a Lambda function. If you want to connect from outside, You will first need something to gain you VPC access like an AWS VPN or a Transit Gateway.

I think this link discusses it - Accessing ElastiCache resources from outside AWS - https://docs.aws.amazon.com/AmazonElastiCache/latest/mem-ug/accessing-elasticache.html#access-from-outside-aws

To add more context if you may be unaware, VPC - Virtual Private Cloud ; basically an atmosphere for all your Cloud resources. Every region you choose to work with will have a default VPC. These Default VPCs have specific IP-address blocks associated to them. When you create a resource within a VPC, one of the IP-address will get associated with one of your resource.

Subents - These are partitions of your VPC. By default, all your Subnets within a VPC are present in different Availability Zones of AWS Datacenter in that region. Eg; N. Virginia has 6 AZs meaning it has 6 distinct locations where your resource can be present. In the default VPCs, each subnet represents one of those locations. When you select a subnet in default VPC, you're basically selecting your AZ. NOTE - In custom made VPC, you can have subnets in the same AZ. That's totally on how you design it.

If you're new to all this, you might want to consider going through AWS docs - https://docs.aws.amazon.com/vpc/latest/userguide/how-it-works.html

They can be very comprehensive. Get some popcorn. :)

Cheers.

tedd_selene
  • 395
  • 1
  • 4
  • 9