Reputation: 1677
I'm doing a server-side application in NestJS that configures Bull to connect to Redis for queues. I have followed the official documentation of NestJS for this purpose here.
Locally, I have 2 Docker containers, one for the NestJS app and another one for Redis. All is working fine using the host as localhost
and the port 6379
to establish the connection between them.
My issue starts when I tried to run a Docker container on Amazon AWS Lightsail Containers with Redis and try to connect to it.
On Amazon AWS Lightsail Containers, I have two containers with this:
In the configuration of my Redis container, I have opened the port 6379 over TCP. And in the configuration of my NestJS container, I did the same thing.
All containers on Lightsail have a public domain and a private domain. I have used the private domain as the host to pass to the Bull configuration, example:
createSharedConfiguration(): Promise<Bull.QueueOptions> | Bull.QueueOptions {
return {
redis: {
host: my-redis.service.local, // <- Private domain of my Redis container
port: 6379,
},
};
}
When I deploy my NestJS app to its container, I receives the following in the console:
(node:17) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 3)
(node:17) UnhandledPromiseRejectionWarning: Error: connect ETIMEDOUT
at Socket.<anonymous> (/app/node_modules/ioredis/built/redis/index.js:308:37)
at Object.onceWrapper (events.js:421:28)
at Socket.emit (events.js:315:20)
at Socket._onTimeout (net.js:483:8)
at listOnTimeout (internal/timers.js:554:17)
at processTimers (internal/timers.js:497:7)
NestJS seems to try to connect but he can't and I don't know why.
What I am missing?
My goal is to connect my server-side application in one container to another container that has Redis on it. Both containers are on Amazon AWS Lightsail Containers.
Upvotes: 2
Views: 843
Reputation: 297
I think you should use container-name as host to connect another container
Upvotes: -1