My ECS Fargate containers & Aurora RDS (Postgres 11.7) database are in the same private subnet of VPC. My ECS only allows inbound access from ALB that's in a public subnet
I have also added ECS security group in the 'Inbound Rules' section of the RDS security group with TCP protocol. Still my dockerized CUBA application is unable to connected to the database. It is using a JDBC url: jdbc:postgresql://cluster writer endpoint/databasename but throwing the following error
03:55:10.672 INFO com.zaxxer.hikari.HikariDataSource - Connection Pool-Main - Starting...
2020-11-20T14:55:10.691+11:00 03:55:10.691 DEBUG com.zaxxer.hikari.pool.PoolBase - Connection Pool-Main - Failed to create/setup connection: The connection attempt failed.
2020-11-20T14:55:10.766+11:00. 03:55:10.702 DEBUG com.zaxxer.hikari.pool.HikariPool - Connection Pool-Main - Cannot acquire connection from data source
2020-11-20T14:55:10.766+11:00 org.postgresql.util.PSQLException: The connection attempt failed.
2020-11-20T14:55:10.766+11:00 at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:292) ~[postgresql-42.2.9.jar:42.2.9]
2020-11-20T14:55:10.766+11:00 at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49) ~[postgresql-42.2.9.jar:42.2.9]
2020-11-20T14:55:10.766+11:00. at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:211) ~[postgresql-42.2.9.jar:42.2.9]
My Aurora database is 'Provisioned' not Serverless. Also, I am able to connect to the database using a Cloud9 EC2 environment within the same VPC( by adding its security-group into the 'Inbound Rules' section of the database security group ).
Any ideas on what could be the issue here. Is there some VPC setting I am missing here or some JDBC driver version issue ?