Skip to content
Home » Error: connect ECONNREFUSED 127.0.0.1:5432 when connecting with nodejs program

Error: connect ECONNREFUSED 127.0.0.1:5432 when connecting with nodejs program

To solve Error: connect ECONNREFUSED 127.0.0.1:5432 when connecting with nodejs program follow any of the below methods.

Error log

Error: connect ECONNREFUSED 127.0.0.1:5432
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1146:16) {
  errno: -111,
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 5432
}

How to solve Error: connect ECONNREFUSED 127.0.0.1:5432 when connecting with nodejs program ?

Refer the below solution to solve the issue.

Error: connect ECONNREFUSED 127.0.0.1:5432 when connecting with nodejs program

Nothing is listening at port 5432, which is where you’ve told PostgreSQL to listen, according to netstat. You can’t connect to it if it’s not listening. Maybe it’s not running; check its log files to discover what happened.

Or Try adding one more rule for ipv4 like:

host    all   all  ::/0  md5

Hope it solves.

Also have a look at : Uncaught Error: Cannot find module ‘react/jsx-runtime’