title: Can't Connect to PostgreSQL RDS from EC2 But works fine from localhost
body: <p>I've been trying to resolve the issue for the past 3 hours now. I have an ec2 instance that is running a tomcat application. I launched it from the eclipse using "Deploy to Elastic Beanstalk option" from aws plugin.</p>
  
  <p>And I have a postgreSQL RDS instance. I am able to connect to the database from the localhost but my ec2 instance can't connect. I've fixed my inbound rules in rds security group to allow all kinds of traffic in. Still no luck. Please help! </p>
  
  <p>Here's the screen from my rds security group on aws console
  <a href="https://i.stack.imgur.com/H3H4E.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/H3H4E.png" alt="enter image description here"></a></p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Here's my vpc and subnet info on ec2 instance:
  <a href="https://i.stack.imgur.com/6PBZg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6PBZg.png" alt="enter image description here"></a></p>
  
  <p>And on my rds instance:
  <a href="https://i.stack.imgur.com/rTvEe.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rTvEe.png" alt="enter image description here"></a></p>
  
  <p>My security group inbound rules on ec2:
  <a href="https://i.stack.imgur.com/TVpV4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TVpV4.png" alt="enter image description here"></a></p>