Node v17 ECONNREFUSED
See original GitHub issueDescription
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:
- Created 2 years ago
- Reactions:1
- Comments:6
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
@marcbachmann is your code running in a container and your DB running in another?