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.

Issue connecting to postgres on localhost

See original GitHub issue

I’m trying to connect my lambda to a local instance of postgres. However, I’m getting the following error. I found this suggestion but that didn’t work either. Any suggestions? Thanks in advance.

{ Error: connect ECONNREFUSED 127.0.0.1:5432
    at Object.exports._errnoException (util.js:1018:11)
    at exports._exceptionWithHostPort (util.js:1041:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1086:14)
  code: 'ECONNREFUSED',
  errno: 'ECONNREFUSED',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 5432 }```

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

46reactions
pawsongcommented, Apr 1, 2018

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

Reference: https://docs.docker.com/docker-for-mac/networking/#use-cases-and-workarounds

7reactions
khamaileoncommented, Sep 3, 2019

@pawsong try this:

sam local start-api --docker-network=host

Works for me after few reloads…

Read more comments on GitHub >

github_iconTop Results From Across the Web

postgres: localhost not connecting - Stack Overflow
In pg_hba.conf: host all all 127.0.0.1/32 trust. last column change to trust.
Read more >
PostgreSQL is running locally but I cannot connect. Why?
Try: psql -U rails -d myapp_development -h localhost.
Read more >
PostgreSQL psql: could not connect to server - nixCraft
Step # 1: Allow remote IP address to access PostgreSQL. You need to open file called /var/lib/pgsql/data/pg_hba. · Step # 2: Allow communication ......
Read more >
Postico User Guide - Connecting to a local PostgreSQL server
This error message usually appears when there is a problem with the /etc/hosts file. Make sure there is an entry for localhost. As...
Read more >
PostgreSQL “Could not connect to server” Error - IONOS
The PostgreSQL error “Could not connect to server: No such file or directory” usually means that PostgreSQL is not running.
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