I set up a basic memcached elasticache cluster and I am trying to now connect to it through express-session in node.js (using the connect-memcached module). I have the following code:
On line 15, I am specifically providing the host server which is my cluster’s configuration endpoint, but it keeps saying either the server is not available or timed out. Note I am running this application on my local machine, but I configured the security group to include all incoming traffic from anywhere. I’m not sure how i’m suppose to connect to the elasticache server. I tried looking everywhere but I can only find a couple of really complicated examples.
You are using the vanilla memcache client it does not support autodiscovery so you can not use the configuration endpoint. Use a elasticache nodejs client instead like https://www.npmjs.com/package/memcached-elasticache or use the specific node endpoints directly.
So it turns out that it doesn’t work from my local machine because elasticache by default doesn’t provide access from outside the vpc. Even if you allow all traffic in, it’s limited to within the vpc. So I pushed the code up onto an EC2 instance and it does indeed work. So just in case anyone comes across this with the same issue, it will only work when running on an ec2 instance, not locally from your personal machine (unless you do some extra setup). https://docs.aws.amazon.com/AmazonElastiCache/latest/mem-ug/accessing-elasticache.html