I have a MySQL database running on an EC2 instance (as opposed to using RDS since this is cheaper). I want to connect to the database in a lambda function, but I keep getting:
(2003, "Can't connect to MySQL server on '' ([Errno 111] Connection refused)")
I have the lambda function on the same VPC and with the same subnet as the EC2 instance (the default VPC) and the security group allows all traffic on all ports. The lambda function has full EC2 access in its permissions. I can verify the MySQL server is up and running and can accept connections from anywhere. I'm totally stumped on what could be causing this issue.
For reference, I'm using PyMySQL to connect:
conn = pymysql.connect(host='<ec2 instance private ip address>', user='<user with all permissions>', passwd='<user password>', db='<database that exists on the MySQL server>', connect_timeout=2)