I’ve setup a Postgres RDS instance and am attempting to launch a service through ECS that connects to this instance. The service is a Scala service deployed as a Dockerfile to ECR. When ECS attempts to spin up a task, CloudWatch shows the following logs:
[ZScheduler-Worker-1] DEBUG c.z.hikari.util.DriverDataSource - Loaded driver with class name org.postgresql.Driver for jdbcUrl=jdbc:postgresql://{endpoint}.us-east-1.rds.amazonaws.com:5432/{database}
[ZScheduler-Worker-1] INFO com.zaxxer.hikari.pool.HikariPool - Hikari-PostgreSQL - Added connection org.postgresql.jdbc.PgConnection@23d97170
[ZScheduler-Worker-1] INFO com.zaxxer.hikari.HikariDataSource - Hikari-PostgreSQL - Start completed.
[ZScheduler-Worker-1] INFO [36mlevel=INFO[0m [37mthread=zio-fiber-6[0m [36mmessage="Datasource configured at jdbc:postgresql://{endpoint}.us-east-1.rds.amazonaws.com:5432/{database}"[0m
[Hikari-PostgreSQL housekeeper] DEBUG com.zaxxer.hikari.pool.HikariPool - Hikari-PostgreSQL - Before cleanup stats (total=1, active=0, idle=1, waiting=0)
[Hikari-PostgreSQL housekeeper] DEBUG com.zaxxer.hikari.pool.HikariPool - Hikari-PostgreSQL - After cleanup stats (total=1, active=0, idle=1, waiting=0)
[Hikari-PostgreSQL connection adder] DEBUG com.zaxxer.hikari.pool.HikariPool - Hikari-PostgreSQL - Added connection org.postgresql.jdbc.PgConnection@19b9a3ff
[Hikari-PostgreSQL connection adder] DEBUG com.zaxxer.hikari.pool.HikariPool - Hikari-PostgreSQL - After adding stats (total=2, active=0, idle=2, waiting=0)
[Hikari-PostgreSQL connection adder] DEBUG com.zaxxer.hikari.pool.HikariPool - Hikari-PostgreSQL - Added connection org.postgresql.jdbc.PgConnection@5cbb2eac
[Hikari-PostgreSQL connection adder] DEBUG com.zaxxer.hikari.pool.HikariPool - Hikari-PostgreSQL - After adding stats (total=3, active=0, idle=3, waiting=0)
[Hikari-PostgreSQL connection adder] DEBUG com.zaxxer.hikari.pool.HikariPool - Hikari-PostgreSQL - Added connection org.postgresql.jdbc.PgConnection@61ead5c5
[Hikari-PostgreSQL connection adder] DEBUG com.zaxxer.hikari.pool.HikariPool - Hikari-PostgreSQL - After adding stats (total=4, active=0, idle=4, waiting=0)
[Hikari-PostgreSQL connection adder] DEBUG com.zaxxer.hikari.pool.HikariPool - Hikari-PostgreSQL - Added connection org.postgresql.jdbc.PgConnection@61762b3d
[Hikari-PostgreSQL connection adder] DEBUG com.zaxxer.hikari.pool.HikariPool - Hikari-PostgreSQL - After adding stats (total=5, active=0, idle=5, waiting=0)
[ZScheduler-Worker-0] INFO com.zaxxer.hikari.HikariDataSource - Hikari-PostgreSQL - Shutdown initiated...
[ZScheduler-Worker-0] DEBUG com.zaxxer.hikari.pool.HikariPool - Hikari-PostgreSQL - Before shutdown stats (total=5, active=0, idle=5, waiting=0)
[Hikari-PostgreSQL connection closer] DEBUG com.zaxxer.hikari.pool.PoolBase - Hikari-PostgreSQL - Closing connection org.postgresql.jdbc.PgConnection@23d97170: (connection evicted)
[Hikari-PostgreSQL connection closer] DEBUG com.zaxxer.hikari.pool.PoolBase - Hikari-PostgreSQL - Closing connection org.postgresql.jdbc.PgConnection@19b9a3ff: (connection evicted)
[Hikari-PostgreSQL connection closer] DEBUG com.zaxxer.hikari.pool.PoolBase - Hikari-PostgreSQL - Closing connection org.postgresql.jdbc.PgConnection@5cbb2eac: (connection evicted)
[Hikari-PostgreSQL connection closer] DEBUG com.zaxxer.hikari.pool.PoolBase - Hikari-PostgreSQL - Closing connection org.postgresql.jdbc.PgConnection@61ead5c5: (connection evicted)
[Hikari-PostgreSQL connection closer] DEBUG com.zaxxer.hikari.pool.PoolBase - Hikari-PostgreSQL - Closing connection org.postgresql.jdbc.PgConnection@61762b3d: (connection evicted)
[ZScheduler-Worker-0] DEBUG com.zaxxer.hikari.pool.HikariPool - Hikari-PostgreSQL - After shutdown stats (total=0, active=0, idle=0, waiting=0)
[ZScheduler-Worker-0] INFO com.zaxxer.hikari.HikariDataSource - Hikari-PostgreSQL - Shutdown completed.
I first thought this had to do with the connection pool not being configured correctly, or potentially security groups. However, when running this code locally I can connect with the instance just fine (it’s set to be publicly accessible to check this). When building the image locally and running that, it gives me the same error as the ECS task does (see above), so it’s likely a Docker issue? I’ve already tried some suggestions passing in a dns flag when running the image, but that does not work.
daansko is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.