Search code examples
postgresqlamazon-web-servicesdockeramazon-rdsamazon-ecs

Docker container on ECS times out when communicating RDS Postgres


I have a dockerized nodejs application on ECS which is supposed to connect to postgres instance located on Amazon RDS.

Locally, I am able to run the docker container and connect (read/write) to the RDS database

When I deploy the container to ECS, I get a timeout when trying to read/write to the RDS Postgres DB.

I built my docker container like so

docker build -t my-app .

I then ran my docker app

docker run -p 80:3000 XXXXXXX

My RDS instance is running at myappdb.ceonhqpz1vl1.us-east-1.rds.amazonaws.com:5432/appdb

I figured this must be a port issue, but I published the ports as stated above. So i figure this must work. But when I run the app through my browser on AWS and try to read/write to the DB, the request takes a long time and then times out.

I'm not sure where to debug at this point, I'm a bit new to docker


Solution

  • There was a setting for the RDS instance inbound traffic source that was set to my local IP; meaning that traffic to the Postgres RDS instance was limited to personal IP address. I changed it and it so the inbound traffic can be from anywhere or 0.0.0.0. This is what I wanted for my use case.