Issue connecting to postgres on AWS SAM?

Sep 21, 2020

šŸ¤” Problem

I'm trying to connect my lambda to a local instance of postgres. However, I'm getting the following error.

Error: connect ECONNREFUSED
syscall: 'connect',
address: '',
port: 5432

āœ… Solution

I resolved this issue by replacing localhost with host.docker.internal.

Docker docs for reference

A handsome man.

I'm Wesley. I live in Boston and work on Wonderment.

Go back to home