Confirm whether there are any Domain Name System (DNS)-related errors. If there are DNS errors, catch them. Then, retry the DNS request using an exponential backoff. For more information, see Error retries and exponential backoff in AWS.
Note: Make sure that you're able to resolve the inbound and outbound endpoints before you retry the DNS request.
Troubleshoot consistent connection timeout errors
Check the Lambda function's Amazon CloudWatch Logs
Note: Because of the way that Lambda reuses containers, Lambda doesn't re-initialize the code that's outside of a function handler when the container is reused. It's a best practice to create the connection that you plan on reusing outside the handler so that it'sstill there on each following invocation. Make sure that you confirm that there's a valid connection before attempting to use the connection. If there's not a valid connection, then create a new connection before continuing.
Create an Amazon Relational Database Service (Amazon RDS) Proxy endpoint for your RDS database to handle the database traffic from your Lambda function. For more information, see Using Amazon RDS Proxy with AWS Lambda.