Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client keeps using 127.0.0.1 but domain is not localhost #756

Closed
20k-ultra opened this issue Dec 5, 2018 · 2 comments
Closed

Client keeps using 127.0.0.1 but domain is not localhost #756

20k-ultra opened this issue Dec 5, 2018 · 2 comments

Comments

@20k-ultra
Copy link

20k-ultra commented Dec 5, 2018

I'm using my Elasticache cluster's configuration endpoint as my client's host value. You can see in the below logs that my host is not 127.0.0.1 BUT the client attempts to connect on 127.0.0.1. Am I not suppose to use my configuration endpoint ?

Even after replacing my configuration endpoint with "redis-cluster-0001-001.s8nphg.0001.use1.cache.amazonaws.com'" which is a actual nodes domain the client still tries to connect to 127.0.0.1

I'm unclear how to perform the binding as mentioned in this issue #156 commented here.
Any advice is appreciated.

ioredis version: 4.2.0
Node v8.11.4

Logs:

// config option i'm passing to ioredis

2018-12-04 23:12:38 REDIS CONFIG: { host: 'redis-cluster.s8nphg.clustercfg.use1.cache.amazonaws.com',
2018-12-04 23:12:38 port: 6379,
2018-12-04 23:12:38 family: 4,
2018-12-04 23:12:38 db: 0 }

// logging what my redis host value domain resolves to with dns.lookup

2018-12-04 23:12:40 redis-cluster.s8nphg.clustercfg.use1.cache.amazonaws.com: 10.0.10.27

// client errors with this:

2018-12-05 15:56:05 { Error: connect ECONNREFUSED 127.0.0.1:6379
2018-12-05 15:56:05 at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1191:14)
2018-12-05 15:56:05 errno: 'ECONNREFUSED',
2018-12-05 15:56:05 code: 'ECONNREFUSED',
2018-12-05 15:56:05 syscall: 'connect',
2018-12-05 15:56:05 address: '127.0.0.1',
2018-12-05 15:56:05 port: 6379 }

Here is my code

import Redis from 'ioredis'
import ENV from './env'

let CLIENT

if (ENV.production) {
  CLIENT = new Redis.Cluster([{
    host: ENV.redis.host,
    port: ENV.redis.port
  }])
} else {
  CLIENT = new Redis({
    host: ENV.redis.host,
    port: parseInt(ENV.redis.port),
    family: 4,
    db: 0
  })
}

CLIENT.on('error', (err) => {
  console.error('redis err: ', err)
  process.exit(1)
})

export default CLIENT
@jayflo
Copy link

jayflo commented Dec 6, 2018

Have you checked this: #365

@20k-ultra
Copy link
Author

I ended up not using a cluster setup until I have more time to research how to do this correctly. I believe the issue is you're suppose to bind your cluster nodes to 127.0.0.1 as mentioned in the issue commented by @jayflo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants