Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node v17 ECONNREFUSED #2643

Open
KhafraDev opened this issue Oct 29, 2021 · 6 comments
Open

Node v17 ECONNREFUSED #2643

KhafraDev opened this issue Oct 29, 2021 · 6 comments

Comments

@KhafraDev
Copy link

KhafraDev commented Oct 29, 2021

Description

On node v16.13.0, connecting to the database works as expected. I decided to try out the changes in v17.0.1 and I can't connect to the db anymore.

Test script:

import pg from 'pg';

export const pool = new pg.Pool({
    user: process.env.POSTGRES_USER,
    password: process.env.POSTGRES_PASS,
    database: 'kb'
});

console.log(process.version);
pool.query(`SELECT NOW()`).then(({ rows }) => console.log(rows[0]));

Output (both versions)

pg>node test
v16.13.0
{ now: 2021-10-29T18:14:27.011Z }
pg>node test
v17.0.1
node:internal/process/promises:246
          triggerUncaughtException(err, true /* fromPromise */);
          ^

Error: connect ECONNREFUSED ::1:5432
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1161:16) {
  errno: -4078,
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '::1',
  port: 5432
}

Node.js v17.0.1

Environment

Windows 10, running postgres from WSL 2

@treysis
Copy link

treysis commented Nov 13, 2021

What does your postgresql.conf file say for listen_addresses?

@KhafraDev
Copy link
Author

commented out, unchanged from install

@treysis
Copy link

treysis commented Nov 21, 2021

@KhafraDev Try changing it to listen_addresses = '127.0.0.1,::1' and see if that works?

@marcbachmann
Copy link

I'm having the same issue with listen_addresses = '*' and running on docker for mac. I assume docker/for-mac#1432 could be the issue here.

@thoroc
Copy link

thoroc commented Oct 18, 2022

@marcbachmann is your code running in a container and your DB running in another?

@marcbachmann
Copy link

marcbachmann commented Oct 18, 2022

Sorry, I'm not sure what the issue was anymore. I was able to upgrade later and everything is running on node 18. Usually we have node outside docker, directly on the mac host, and then postgres within docker.
Maybe I posted the comment above when I was trying to run it within our CI or on macos, therefore completely in docker. I can report back here in case it's still failing as I'll upgrade to node 18 within the next 2 weeks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants