Express + Knex + RDS (postgres) = Internal server error?

Hey all. Pretty new to this so apologies if I misspeak on anything.

Right now I’m using serverless-http to run my express app. I’m able to ping a simple hello world endpoint from postman, however whenever I attempt to connect to my RDS through Knex, I always timeout (around 6 seconds) and get an “Internal Service Error”.

My vpc in my serverless.yaml is set with the appropriate securityGroupIds/subnetIds

provider:

name: aws
runtime: nodejs8.10
region: us-east-1
vpc:
securityGroupIds:
- sg-########
subnetIds:
- subnet-########
- subnet-########
- subnet-########
- subnet-########
- subnet-########
- subnet-########

Does anyone know what could be the issue, whether with rds or serverless? As well, does anyone have any tips on debugging issues like this that give the opaque internal server error? Much appreciated!

Make sure you are logging your errors and then take a look at CloudWatch logs to see what the issue is. It sounds like your Lambda is throwing errors that you’re not catching, so an invalid response is being sent to API Gateway.

Also, look at using the serverless-offline plugin so that you can run your API locally. You can either connect to a local database, or use a VPN or SSH tunnel to connect to your remote one for testing.

Ah yes I forgot to mention that the app works fine when running on serverless-offline and a local postgres instance, which is why I suspect it is something to do with rds/vpc configuration.

As well, I attempted to console log like

   try{
       console.log(1)
       Knex Call
   }
   catch{
       console.log(2)
   }

I don’t see console.log(2) when I tail via sls logs

I will check cloudwatch later today, thanks for the tips

Yeah, no errors are present or loggable. I imagine it’s a timeout/connection issue. My handler looks like

    module.exports.handler = async (event, context) => {
	context.callbackWaitsForEmptyEventLoop = false
  return await handler(event, context);
};

so callbackWaitsForEmptyEvenyLoop shouldn’t be causing the issue.
Do you know what the error could be?