Why can't I find my RDS database from my lambda function?
I am trying to connect a lambda function to my RDS database. They both have the same subnets, VPS, and security groups, but whenever I try to run code to connect to the database, I get an error saying that it wasn't found. The database also isn't showing up as an available database proxy. Do you know how I can get this to appear?
@SandeepVudata The database was created. The error message says "ERROR: Unexpected error: Could not connect to MySQL instance. (1049, "Unknown database 'database_name'")" I have my database connection in a try except block, and this is the exact error that is supposed to be thrown when I can't connect to the database. I am trying to connect by using pymysql.connect() with the endpoint, username, password, and db name as parameters, but the code can't find the name of the database even though it is correct.
Hello, not sure if you already did this, but just including two instances (in your case lambda and rds) in the same subnet and the same security group doesn't open any communication ports - you need to define the specific security rules to open the DB port for communication.
If you want to keep them in the same security group, you'll have to create a self-referencing rule in this group with the right DB port to open (depending on your database engine) and indicating the source as the same security group.
Regards
Relevant questions
Bypass CORS policy on S3-hosted site connected to RDS database
asked 2 months agoInternal Server Error from API Gateway when sending queries through gateway to Lambda function connected to RDS database
asked 2 months agoTimeout when performing an "INSERT" query into RDS Aurora DB?
asked 2 years agoIssues connecting to Postgres RDS instance from within a VPC
asked 3 years agoWhy can't I find my RDS database from my lambda function?
asked 2 months agoRotation lambda timing out but using Secrets Manager VPC Endpoint
asked 2 years agoHow to connect MySQL database in nodeJS file.
asked 2 years agoHandler error when connecting lambda function to RDS database
asked 2 months agoAWS Lambda not able to connect to public RDS instance
asked a month agoCan't connect to an RDS Instance from Lambda (different account tough)
asked 2 years ago
Was Database created? What is the exact error message?