title: Redis Cluster and node ioredis: Connect to remote redis cluster for development
body: <p>I'm having trouble getting my app to connect to a remote redis cluster locally. With a single node/connection it's quite easy:</p>
  
  <p><code>ssh -f -N -L6379:localhost:6379 user@{{ remote_ip }}</code></p>
  
  <p>And then redis can be connected to directly through local port 6379.</p>
  
  <p>But the same doesn't work for a multi-node cluster setup. I tried forwarding each port using the above line of code for every node <code>6379, 6380, 6381, etc.</code> but the cluster connections cannot be made. I assume this is because the cluster node config refers necessarily to the actual private IP of the remote server so my local ports cannot be connected together.</p>
  
  <p>This is how I am connected to redis:</p>
  
  <pre><code>var Redis = require('ioredis');
  
  var host = ENV.MARKET_REDIS_HOST;
  var ports = [ 0, 1, 2 ];
  var nodes = [];
  
  ports.forEach((port)=&gt;{
       nodes.push({
           port: 6379 + port,
           host: ENV.MARKET_REDIS_HOST,
       });
  });
  
  var ms_redis = new Redis.Cluster(nodes);
  </code></pre>
  
  <p><code>ENV.MARKET_REDIS_HOST</code>is set to localhost in dev (doesn't work), and to the actual private ip in prod (which works)</p>