Reputation: 783
I want to test if my ec2 instance can connect to my database.
I ssh into my instance ran the command:
echo '\dS' |psql -h rds-endpoint-xxx.amazonaws.com 5432
psql: error: could not connect to server: Operation timed out
Is the server running on host "rds-endpoint-xxx.amazonaws.com" (192.168.12.233) and accepting
TCP/IP connections on port 5432?
What does this mean? and what should i do to fix?
Upvotes: 1
Views: 172
Reputation: 238467
Unless your two VPC are peered, you will not be able to access your RDS from the instance due to your security group (SG). Without peering, the connection from the instance to the rds will go over internet, and your SG does not allow internet connections.
To solve this, you either have to peer your VPCs, which you can't do right now as they have same CIDRs. For peering you need non-overlapping CIDRs for the VPC.
Alternative is to allow internet connections to your RDS, which means you need to allow incoming traffic (0.0.0.0/0) unless you have EIP for the instance. Also RDS must be set to be allow public connections.
Upvotes: 1