PostreSQL - Server wasn't able to start properly - no pg_hba.conf entry for host xxx.xxx.xxx.xxx Error

System Information
  • Strapi Version: v4.0.2
  • Operating System: Ubuntu 20.04.3 LTS
  • Database: PostgreSQL 14
  • Node Version: v16.13.1
  • NPM Version: 8.1.2
  • Yarn Version: 1.22.17

Hello there,
I’ve opened an issue for this error, but ticket were closed, asking me to post here because “not really a bug report” (?!)

This is the problem: with a Strapi fresh install that I’m trying to connect to a remote PostgreSQL database, server fail to start with this error:

[2021-12-31 13:16:32.632] debug: no_entry Server wasn’t able to start properly.
[2021-12-31 13:16:32.633] error: no pg_hba.conf entry for host “109.190.xxx.xxx”, user “avnadmin”, database “defaultdb”, no encryption
error: no pg_hba.conf entry for host “109.190.xxxx.xxxx”, user “avnadmin”, database “defaultdb”, no encryption
at Parser.parseErrorMessage (/home/my/app/path/my-strapi/node_modules/pg-protocol/dist/parser.js:287:98)
at Parser.handlePacket (/home/my/app/path/my-strapi/node_modules/pg-protocol/dist/parser.js:126:29)
at Parser.parse (/home/my/app/path/my-strapi/node_modules/pg-protocol/dist/parser.js:39:38)
at Socket. (/home/my/app/path/my-strapi/node_modules/pg-protocol/dist/index.js:11:42)
at Socket.emit (node:events:390:28)
at Socket.emit (node:domain:475:12)
at addChunk (node:internal/streams/readable:315:12)
at readableAddChunk (node:internal/streams/readable:289:9)
at Socket.Readable.push (node:internal/streams/readable:228:10)
at TCP.onStreamRead (node:internal/stream_base_commons:199:23)
error Command failed with exit code 1.
info Visit yarn run | Yarn for documentation about this command.

Steps to reproduce the behavior

1- Use yarn command for setup, without --quickstart option
2- Choose custom (manual settings)
3- select postgres
4- enter db parameters (dbname, host, port, username, password)
5- select No for “Enable SSL connection”
6- launch the app with “yarn develop” command

A workaround is modifying the databases.js file, like I saw somewhere on the net:
Replace the line

ssl: env.bool('DATABASE_SSL', false),

with

ssl: { rejectUnauthorized: env.bool('DATABASE_SSL_SELF', false), },


So, is it a bug or not ? :slight_smile:

1 Like

I’m facing this same issue. Is there any solution ?

Hello, were you able to find a solution to this issue?

The problem is that we are trying to connect to (ssl enabled) database without any ssl certificate and that’s why it doesn’t allow to make the connection. The solution is either we need to use a ssl certificate to connect the db or we need to change the db settings.

I resolved this by disabling force_ssl in the db configurations. I used aws rds postgres db 15 version. The force_ssl is true by default for versions above 14 in rds.

Check the postgres version and make sure ssl is false in database configuration.

I’m sharing the links that helped me.

1 Like