question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can not connect to local database on Ubuntu

See original GitHub issue

I 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:open
  • Created a year ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
nazShg48commented, Oct 6, 2022

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.

0reactions
nazShg48commented, Nov 17, 2022

Any updates here?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot connect to Database server (mysql workbench)
The problem is that MySQL server is not installed. · Click on the Start button on a Windows machine · Type services and...
Read more >
How to resolve Cannot connect to Database server (mysql ...
Not able to connect Database server on MySQL Workbench? Solve this error with a simple ALTER command: Step 1 Open terminal and type...
Read more >
Database connection error - mysql - Ask Ubuntu
Check that your mysql server is running, if not enable it. From a terminal, $ sudo systemctl enable mysql Synchronizing state of ...
Read more >
How To Connect to a Managed Database on Ubuntu 18.04
If you're connecting to a DigitalOcean Managed Database, you can find all of this connection information in your Cloud Control Panel. Click on ......
Read more >
How to Fix Cannot Connect to Database Server MySQL ...
In This Video We Will See How to Fix Cannot Connect to Database Server MySQL Workbench Error or Cannot Connect to MySQL ServerHere...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found