[solved] Can't connect to external database

I need to connect to a legacy mysql database from a serverless service. It works on when developing on local but not when I deploy to AWS.

The connection timeout

How can I do it?

If you’re getting a timeout it’s probably a network issue so without more information about your network topology it’s going to be difficult to debug.

The most common problem with database connectivity is you’re deploying to Lambda outside a VPC but trying to connect to an RDS instance inside a VPC. For that the simple solution is deploy your Lambda inside your VPC.

My database is external to AWS, not in RDS neither EC2

Is the database accessible from any IP address?

Have you set context.callbackWaitsForEmptyEventLoop = false; in your Lambda?


Oh, yeah! It worked! Thanks!

I guess is time to dig up on the lambda context


It worked @buggy