Elastic Beanstalk app won't connect to RDS MySQL instance

Tim Jahn picture Tim Jahn · Oct 18, 2015 · Viewed 13k times · Source

I have a CodeIgniter PHP app setup on an Elastic Beanstalk instance. I'm trying to connect it to a RDS MySQL instance I setup but loading the Elastic Beanstalk site URL always results in the page timing out the connection. I've narrowed down the issue to not being able to connect to the database.

I think I've setup my security groups properly to allow the Elastic Beanstalk EC2 instances to talk to RDS, but something must be wrong as the page still doesn't load.

I've included screenshots below of the inbound/outbound rules for the security group that RDS and Elastic Beanstalk use, as well as a screenshot of what security groups I have attached to the Elastic Beanstalk instance.

Inbound rules

Outbound rules

enter image description here

Any ideas as to why my Elastic Beanstalk app can't talk to my RDS instance?


EDIT: The RDS instance and the Elastic Beanstalk instance are in the same security group.

Answer

Gustaf picture Gustaf · Oct 19, 2015

Add the stack security group name you have your Elastic Beanstalk set up with to the list of RDS security groups.

It is easiest to test by logging into the EC2-instance (i.e. eb ssh) and test the connection to the database to exclude any issues with your app.

mysql -u user -p password -h rds.instance.endpoint.region.rds.amazonaws.com