title: AWS Lambda Connecting to Local Postgres in Docker
body: <p>I'm attempting to connect to a local Postgres server running as a docker container from my Lambda function.</p>
  
  <p>I'm using the <code>sam local invoke</code> call to do so.</p>
  
  <p>For some reason, it seems that outgoing connection from SAM's docker container for the function is disabled.</p>
  
  <p>I'm getting this error message:</p>
  
  <pre><code>"errorMessage": "(psycopg2.OperationalError) could not connect to server: Connection refused\n\tIs the server running on host \"localhost\" (127.0.0.1) and accepting\n\tTCP/IP connections on port 5432?\ncould not connect to server: Cannot assign requested address\n\tIs the server running on host \"localhost\" (::1) and accepting\n\tTCP/IP connections on port 5432?\n\n(Background on this error at: http://sqlalche.me/e/e3q8)",
  </code></pre>
  
  <p>Is there a way to enable a Lambda function call to a <strong>local</strong> docker database?</p>
  
  <p><em>I have no issues running the connection code outside the Lambda function as standard Python code - so I'm sure my database is up, my code works, etc.</em></p>