amazon-web-servicesrdsamazon-aurora

Amazon RDS db connects locally but not on production


I was able to connect to the amazon rds aurora database locally, and run queries.

But on production EC2 server, the connection returns 500 server error "SQLSTATE[HY000] [2002] Connection timed out".

How could it be working locally but not on production?


Solution

  • It was a security group issue.

    The default rds-setup-wizard security group was applied to my database instance, and this gave me local access. I guess it had my ip address or similar as an inbound rule.

    I had to add a new security group and add that new group to the database instance.

    My new security group needed an inbound rule that looked like this:

    Type: MYSQL/Aurora
    Protocol: TCP
    Port Range: 3306
    Source: my EC2's private ipv4 address with /32. Eg: 13.14.15.16/32