The app cannot connect to RDS: `psql: error: connection to server at "mydb.abc.us-east-1.rds.amazonaws.com" (10.0.3.12), port 5432 failed: Connection timed out`.
BeginnerTroubleshootingRDS, Aurora and DynamoDB
Answer
Likely causes → A timeout means the packets are dropped. The DB SG does not allow 5432 from the app SG, a NACL blocks it, or the client is outside the VPC (for example, a laptop) while the DB is not publicly accessible (which is how it should be).
Diagnose →
aws rds describe-db-instances --db-instance-identifier mydb \
--query 'DBInstances[].[Endpoint.Address,Endpoint.Port,PubliclyAccessible,VpcSecurityGroups,DBSubnetGroup.Subnets[].SubnetIdentifier]'
nc -zv mydb.abc.us-east-1.rds.amazonaws.com 5432
aws ec2 describe-security-groups --group-ids <db-sg> --query 'SecurityGroups[].IpPermissions'
Fix →
- Allow 5432 on the DB SG from the app SG
- From a laptop, use SSM port forwarding through a bastion:
aws ssm start-session --target i-0abc --document-name AWS-StartPortForwardingSessionToRemoteHost --parameters host=mydb...,portNumber=5432,localPortNumber=5432
Prevent → Keep databases in private subnets and grant access by SG reference only.
More on RDS, Aurora and DynamoDB
`FATAL: password authentication failed for user "postgres"` and nobody knows the master password.Beginner`FATAL: no pg_hba.conf entry for host "10.0.1.25", user "app", database "orders", no encryption`.IntermediateApp logs show `FATAL: remaining connection slots are reserved for non-replication superuser connections` (or MySQL `ERROR 1040 (HY000): Too many connections`).IntermediateRDS status shows `storage-full` and writes fail.IntermediateA read replica's `ReplicaLag` keeps growing and reports show stale data.IntermediateAfter a Multi-AZ failover, some app servers keep failing with connection errors for 10+ minutes while others recover in a minute.Advanced