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.

Node v17 ECONNREFUSED

See original GitHub issue

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

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:6

github_iconTop GitHub Comments

1reaction
marcbachmanncommented, 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.

0reactions
thoroccommented, Oct 18, 2022

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

connect ECONNREFUSED ::1:27017 in node v17 and mongo ...
ECONNREFUSED means the operating system actively refused the connection because nothing is listening on ::1:27017 . Did you configure mongod to ...
Read more >
error: connect econnrefused 127.0.0.1:5432 at ... - You.com
Where does your pgadmin run? If it runs on the same host as the postgres database, then 127.0.0.1 is correct from its perspective....
Read more >
connect ECONNREFUSED when running node JS Debugger
Error in debuggerConnector: connect ECONNREFUSED when running node JS Debugger · If the issue was reproduced and assigned to the responsible developer, its ......
Read more >
Errors | Node.js v19.3.0 Documentation
ECONNREFUSED (Connection refused): No connection could be made because the target machine actively refused it. This usually results from trying to connect ...
Read more >
1:27017 in node v17 and mongo is running-node.js
[Solved]-MongooseServerSelectionError: connect ECONNREFUSED ::1:27017 in node v17 and mongo is running-node.js ... I am using node v17.0.1 . Node v17 prefers IPv6 ...
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