My lambda function written in Golang is not able to connect to the postgres database that is running locally on my machine (127.0.0.1:5432
or localhost:5432
). The credentials and the function code are correct! I ensured it by copying the code and running it from a regular Go app.
This is the error message I am getting:
{"errorType":"OpError","errorMessage":"dial tcp 127.0.0.1:5432: connect: connection refused"}
Further…
Error --------------------------------------------------
Error: Failed to run docker for go1.x image (exit code 1})
at /Users/me/Projects/my-functions/node_modules/serverless/lib/plugins/aws/invokeLocal/index.js:536:21
For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.
Get Support --------------------------------------------
Docs: docs.serverless.com
Bugs: github.com/serverless/serverless/issues
Issues: forum.serverless.com
Your Environment Information ---------------------------
Operating System: darwin
Node Version: 14.3.0
Framework Version: 2.15.0 (local)
Plugin Version: 4.2.0
SDK Version: 2.3.2
Components Version: 3.4.3
So somehow when invoking the function with sls, it cannot access the postgres service running on my machine I assume. This is the command I use: sls invoke local -f myFunction
I need help to get this to work