Skip to content

PostgreSQL connection error when declaring No for SSL #12058

@raclepoulpe

Description

@raclepoulpe

Bug report

Server don't start when PostgreSQL database configuration is setted with SSL: No

Describe the bug

Server doesn't start when PostgreSQL is configured with no SSL

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

Expected behavior

A started server

Screenshots

Admin UI built successfully
[2021-12-31 13:16:32.632] debug: ⛔️ 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 https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Code snippets

N/A

System

  • Node.js version: v16.13.1
  • NPM version:8.1.2
  • Strapi version: v4.0.2
  • Database: PostgreSQL 14 (OVHcloud managed)
  • Operating system: Ubuntu 20.04.3 LTS

Additional context

A workaround is modifying the databases.js file

replace the line
ssl: env.bool('DATABASE_SSL', false),
with
ssl: { rejectUnauthorized: env.bool('DATABASE_SSL_SELF', false), },

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions