I have a Load Balanced Web service deployed:
About
Application my-app
Name api
Type Load Balanced Web Service
Configurations
Environment Tasks CPU (vCPU) Memory (MiB) Port
----------- ----- ---------- ------------ ----
production 1 0.25 512 80
Routes
Environment URL
----------- ---
production http://xxxxx.us-east-1.elb.amazonaws.com
Service Discovery
Environment Namespace
----------- ---------
production api.my-app.local:80
Variables
Name Container Environment Value
---- --------- ----------- -----
COPILOT_APPLICATION_NAME " " my-app
COPILOT_ENVIRONMENT_NAME " " production
COPILOT_LB_DNS " " xxxx.us-east-1.elb.amazonaws.com
COPILOT_SERVICE_DISCOVERY_ENDPOINT " " my-app.local
COPILOT_SERVICE_NAME " " api
REDIS_URL " " redis://redis.my-app.local:6379
And redis as backend service in the same copilot application:
About
Application my-app
Name redis
Type Backend Service
Configurations
Environment Tasks CPU (vCPU) Memory (MiB) Port
----------- ----- ---------- ------------ ----
production 1 0.25 512 6379
Service Discovery
Environment Namespace
----------- ---------
production redis.my-app.local:6379
Variables
Name Container Environment Value
---- --------- ----------- -----
COPILOT_APPLICATION_NAME redis production my-app
COPILOT_ENVIRONMENT_NAME " " production
COPILOT_SERVICE_DISCOVERY_ENDPOINT " " my-app.local
COPILOT_SERVICE_NAME " " redis
When I look at the records on Route53, redis.my-app.local
is present. But then the logs in my api always say:
uncaughtException: Redis connection to redis.my-app.local:6379 failed - getaddrinfo ENOTFOUND redis.my-app.local
Then at some point redis shuts down because there is no incoming connection... what is the issue?
It looks like you found the solution: DNS hostnames must be enabled.
For others who may encounter the same issue:
By default, Copilot does:
EnableDnsHostnames: true
EnableDnsSupport: true
We will add a warning for imported VPCs, but in the meantime, ensure that you have DNS hostnames enabled for your existing VPC.