Skip to content

Strapi does not work with latest version of the pg package #5696

@hissalht

Description

@hissalht

Describe the bug
Latest version of the pg package (8.0.0) is not compatible with strapi.

Steps to reproduce the behavior

  1. Install the pg package like described here https://strapi.io/documentation/3.0.0-beta.x/guides/deployment.html#_5-install-the-pg-node-module
  2. Start the server with the following config.
{
  "defaultConnection": "default",
  "connections": {
    "default": {
      "connector": "bookshelf",
      "settings": {
        "client": "postgres",
        "host": "${process.env.DATABASE_HOST}",
        "port": "${process.env.DATABASE_PORT}",
        "database": "${process.env.DATABASE_NAME}",
        "username": "${process.env.DATABASE_USERNAME}",
        "password": "${process.env.DATABASE_PASSWORD}",
        "ssl": true
      },
      "options": {}
    }
  }
}
  1. The server fails to start with the following error.
➜  project-folder git:(master) ✗ yarn develop 
yarn run v1.22.0
$ strapi develop
[2020-04-02T22:06:49.564Z] error Impossible to register the 'model-name' model.
[2020-04-02T22:06:49.568Z] error Error: self signed certificate
    at TLSSocket.onConnectSecure (_tls_wrap.js:1473:34)
    at TLSSocket.emit (events.js:311:20)
    at TLSSocket._finishInit (_tls_wrap.js:916:8)
    at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:686:12)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Expected behavior
When I start the server in production mode, the connection to the DB is made.

How to fix
Install the last 7.x.x version instead.

yarn add pg@^7.18.2

Note
The 7.18.2 version of pg shows a deprecation warning.

(node:3130) DeprecationWarning: Implicit disabling of certificate verification is deprecated and will be removed in pg 8. Specify `rejectUnauthorized: true` to require a valid CA or `rejectUnauthorized: false` to explicitly opt out of MITM protection.

System

  • Node.js version: v12.16.1 LTS
  • Strapi version: 3.0.0-beta.19.3
  • Database: PGSQL
  • Operating system: Ubuntu WSL on windows/heroku dyno

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