1

I set up RDS (mysql) with Elastic Beanstalk/EC2 on AWS for my PHP API.

The API is reachable through http and https, but it seems the connection to the DB is having troubles, as I'm getting error:

"SQLSTATE[HY000] [2002] Connection timed out","error_data":

What I've checked:

  • My PHP app is load balanced, with a SSL cert attached, and served through https through cloudfront. The security group assigned to this EC2 instance is the same as I'm using for RDS, with inbound rules that accept http connection (it's also attached to the default RDS security group which allows it to be in authorized state)

enter image description here

  • RDS instance in authorized state given its security groups: enter image description here

  • I can connect to the DB instance through my credentials in sequel pro

  • I've double checked my elastic beanstalk env variables, which are the same as I used to log in successfully to sequel pro on the server

I checked the server logs and am not getting much more detail about why I cannot connect.


EDIT: added inbound settings for MYSQL

enter image description here

  • Can you connect to RDS from an EC2 instance started by EB? The security group that contains RDS must allow connections on the appropriate ports, which are labeled in the security group settings - eg MySQL. Have a look here. – Tim Apr 19 '17 at 5:16
  • @Tim ah so on the inbound settings, I need to add MYSQL as shown above in the added picture? – Growler Apr 19 '17 at 5:22
  • @Tim I've gone through your setup process (thanks for the link). Two things: 1) I've added the inbound settings for port 3306. 2) My VPC w/ subnets were set up for me when I created Elasticbeanstalk instance with RDS. Still getting the same SQL connection error – Growler Apr 19 '17 at 5:38
  • @Tim solved: had the port as part of the env variable for the DB host string :/ – Growler Apr 19 '17 at 5:45
  • Ah I did a couple of days ago myself. Suggest you answer your own question, it may help someone out. Give a bit of detail, or link to docs. – Tim Apr 19 '17 at 9:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.