skip to Main Content

I am trying to connect to aws elasticache from my app.

I know the endpoint and the port but for some reason I can’t connect to it.

I used this npm package:
https://www.npmjs.com/package/node-memcached-client

code:

const Memcached = require('node-memcached-client');
const client = new Memcached({
  host: 'mycache.aa11c.0001.use2.cache.amazonaws.com', //fake aws cache endpoint
  port: 11211
});
console.log(client); // I can see it outputs stuff

client.connect()
    .then(c => {
        console.log('connected');
        console.log(c);

    }).catch(function(err){
        console.log('error connecting');
        console.log(err);
    });

For some reason when I run the codes, all I see is

[Memcached] INFO: Nothing any connection to mycache.aa11c.0001.use2.cache.amazonaws.com:11211, created sid:1

no errors or connected message in the console.log. Am I doing something wrong here?

Thanks!

2

Answers


  1. Chosen as BEST ANSWER

    I ended using port forwarding to bypass the local instance can't connect to elasticache issue.

    by using

    ssh -L 11211:{your elasticache endpoint}:11211 {your ec2 instance ip}
    

  2. You may want to go over the below document from AWS to access Elasticache resources from outside of AWS:

    Access AWS Elasticache from outside

    I would recommend setting up a local memcached instance for development and debugging, and connect to Elasticache from an EC2 instance in test and production environments.

    The ROI for trying to setup NAT and mapping the IP addresses is not justifiable for dev/test unless absolutely necessary.

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