App logs show `FATAL: remaining connection slots are reserved for non-replication superuser connections` (or MySQL `ERROR 1040 (HY000): Too many connections`).
IntermediateTroubleshootingRDS, Aurora and DynamoDB
Answer
Likely causes → You have hit max_connections. Usually too many app replicas each open a large pool, or Lambda functions open a new connection per invocation, or connections leak.
Diagnose →
aws cloudwatch get-metric-statistics --namespace AWS/RDS --metric-name DatabaseConnections \
--dimensions Name=DBInstanceIdentifier,Value=mydb --statistics Maximum --period 60 \
--start-time $(date -u -d '-2 hour' +%FT%TZ) --end-time $(date -u +%FT%TZ)
psql -c "select usename, application_name, state, count(*) from pg_stat_activity group by 1,2,3 order by 4 desc;"
Fix →
- Shrink the pool per pod: total = replicas × pool size, which must stay under max_connections
- Put RDS Proxy (or PgBouncer) in front for Lambda and bursty clients
- Kill idle connections and set
idle_in_transaction_session_timeout
Prevent → Budget connections per service, alarm at 80% of max, and use RDS Proxy for serverless callers.
More on RDS, Aurora and DynamoDB
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`.Beginner`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`.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