← Back to all fixes
AWS

Application cannot connect to RDS

The Issue

App throws: `could not connect to server: Connection timed out — Is the server running on host "mydb.xxx.rds.amazonaws.com"`

Root Cause

RDS security group does not allow inbound traffic from the app server, or RDS is in a private subnet the app cannot reach.

How to Fix
  1. Check RDS security group — it must allow inbound on port 5432 (Postgres) or 3306 (MySQL) from the app's security group or IP
  2. Ensure both app and RDS are in the same VPC, or VPC peering is configured
  3. RDS should be in private subnets — app accesses it via VPC, not public internet
  4. Test connectivity from app server: `nc -zv mydb.xxx.rds.amazonaws.com 5432`
  5. Check RDS instance is in "Available" state in the console