Can not connect to local database on Ubuntu
See original GitHub issueI get timeout error or connection to server at "one of the host names that i use" port 5432 failed: Connection refused
when trying to connect to a postgresql that I have locally on my OS, Ubuntu 18.04.6 LTS, from a lambda that is running in sam.
In pg_hba.conf
I set 0.0.0.0/0
for all IPv4 connection just to ensure that it is not an issue.
Database is working fine as I can use it from other applications that I am running on my local machine, but they are not using sam.
I used all possible combinations for the database host: 172.17.0.1
which is address of docker0
, localhost
, 127.0.0.1
, host.docker.internal
And commands to run aws sam: sam local start-api --docker-network host
, sam local start-api
, sam local start-api --container-host localhost --container-host-interface 0.0.0.0 --docker-network host
, sam local start-api --container-host localhost --container-host-interface 0.0.0.0
and some others.
Result is the same, either timeout error or connection to server at {one of the host addresses} port 5432 failed
SAM CLI, version 1.56.1
Issue Analytics
- State:
- Created a year ago
- Comments:7 (2 by maintainers)
I haven’t tried it since I need to connect from SAM to local PG instance which is not in docker, but running locally. I and my teammate tried to use SAM on his machine, with Ubuntu 22.04 LTS , same problem. I am pretty sure it is universal problem.
Any updates here?