ECS task timeouts connecting to RDS
My ECS container will connect to my RDS database initially and can even run a query. However very quickly after boot up, the connection will time out.
The error sometimes looks like a DNS one with the error message of:
- OperationalError('[Errno -3] Temporary failure in name resolution')
Sometimes its a connection timeout:
- OperationalError('connection timeout expired')
Notes and things I've tried:
- Security group has 5432 open, but I've tried having all ports open.
- Same VPC and different VPC
- My App Runner app can connect to the DB flawlessly (same code)
- My computer can connect to the database (same code)
- EC2 instances can connect to the database (same code)
- ECS container's role with RDS access, which doesn't make sense but I'm grasping at straws
- RDS is publicly accessible
I'm running Django 5.1 on Python 3.12.
I'm seriously out of solutions and am considering migrating off ECS to something else.