liaoliaots / nestjs-redis

Redis module for Nest framework (node.js). Support node-redis & ioredis.
MIT License
392 stars 71 forks source link

Error: connect ETIMEDOUT #462

Open jeffminsungkim opened 1 year ago

jeffminsungkim commented 1 year ago

Your issue may already be reported! Please search on the issue tracker before creating one.

Expected Behavior

AWS ElasticCache connection should be established without having an issue.

Current Behavior

AWS Security Group's inbound rule is open to public (0.0.0.0).


RedisModule.forRootAsync({
    imports: [ConfigModule],
    inject: [ConfigService],
    useFactory: (config: ConfigService) => ({
      config: {
        host: 'aws-elastic-cache-url',
        port: config.get('REDIS_PORT') || 6379,
        password: config.get('REDIS_PASSWORD'),
      },
    }),
  }),

I'm facing the following error.

[Nest] 77739  - 03/16/2023, 5:50:05 PM   ERROR [RedisModule] default: connect ETIMEDOUT +10056ms
Error: connect ETIMEDOUT
    at Socket.<anonymous> (/Users/x/Projects/workspace/backend/node_modules/ioredis/built/Redis.js:170:41)
    at Object.onceWrapper (node:events:627:28)
    at Socket.emit (node:events:513:28)
    at Socket._onTimeout (node:net:562:8)
    at listOnTimeout (node:internal/timers:564:17)
    at processTimers (node:internal/timers:507:7)

If I try with my localhost redis, it works fine.

Possible Solution

Steps to Reproduce (for bugs)

1. 2. 3. 4.

Context

Your Environment

jeffminsungkim commented 1 year ago

I've heard that the Elasticache is a service designed to be used internally to a specific VPC. Is this the possible reason why the connection issue occurred?