Skip to content

Documentation for PostgreSQL/MySQL/MariaDB is wrong regarding SSL #281

@SalahAdDin

Description

@SalahAdDin

Bug report

At initializing a new project with postgres in a docker stack, we are getting Error: The server does not support SSL connections.

Describe the bug

At running the stack we are looking:

strapi_1    | Starting your app...
postgres_1  | 2021-05-09 19:11:20.933 UTC [1] LOG:  database system is ready to accept connections
strapi_1    | [2021-05-09T19:11:26.464Z] debug ⛔️ Server wasn't able to start properly.
strapi_1    | [2021-05-09T19:11:26.466Z] error Error: The server does not support SSL connections
strapi_1    |     at Socket.<anonymous> (/srv/app/node_modules/pg/lib/connection.js:71:37)
strapi_1    |     at Object.onceWrapper (events.js:421:26)
strapi_1    |     at Socket.emit (events.js:314:20)
strapi_1    |     at addChunk (_stream_readable.js:297:12)
strapi_1    |     at readableAddChunk (_stream_readable.js:272:9)
strapi_1    |     at Socket.Readable.push (_stream_readable.js:213:10)
strapi_1    |     at TCP.onStreamRead (internal/stream_base_commons.js:188:23)

Steps to reproduce the behavior

  1. Initialize a new project.
  2. Setup the docker compose file.
  3. Launch the stack.
  4. See error

Expected behavior

We should not see any problem and we should see the admin page.

Screenshots

If applicable, add screenshots to help explain your problem.

Code snippets

./config/database:

module.exports = ({ env }) => ({
  defaultConnection: "default",
  connections: {
    default: {
      connector: "bookshelf",
      settings: {
        client: "postgres",
        host: env("DATABASE_HOST", "localhost"),
        port: env.int("DATABASE_PORT", 5432),
        database: env("DATABASE_NAME", "strapi"),
        username: env("DATABASE_USERNAME", "strapi"),
        password: env("DATABASE_PASSWORD", "strapi"),
        schema: env("DATABASE_SCHEMA", "public"), // Not Required
        ssl: {
          rejectUnauthorized: env.bool("DATABASE_SSL_SELF", false), // For self-signed certificates
        },
      },
      options: {
        ssl: false,
      },
    },
  },
});

docker-compose.yml:

version: '3'
services:
  strapi:
    image: strapi/strapi
    environment:
      DATABASE_CLIENT: postgres
      DATABASE_NAME: strapi
      DATABASE_HOST: postgres
      DATABASE_PORT: 5432
      DATABASE_USERNAME: strapi
      DATABASE_PASSWORD: strapi
    volumes:
      - ./backend:/srv/app
    ports:
      - '1337:1337'
    depends_on:
      - postgres

  postgres:
    image: postgres
    environment:
      POSTGRES_DB: strapi
      POSTGRES_USER: strapi
      POSTGRES_PASSWORD: strapi
    volumes:
      - ./data:/var/lib/postgresql/data

package.json:

"dependencies": {
    "knex": "0.21.18",
    "pg": "^8.6.0",
    "pg-connection-string": "^2.5.0",
    "strapi": "^3.6.1",
    "strapi-admin": "3.6.1",
    "strapi-connector-bookshelf": "^3.6.1",
    "strapi-plugin-content-manager": "3.6.1",
    "strapi-plugin-content-type-builder": "3.6.1",
    "strapi-plugin-email": "3.6.1",
    "strapi-plugin-graphql": "3.6.1",
    "strapi-plugin-i18n": "3.6.1",
    "strapi-plugin-upload": "3.6.1",
    "strapi-plugin-users-permissions": "3.6.1",
    "strapi-utils": "3.6.1"
  },

System

  • Node.js version: 12.20.1
  • NPM version:
  • Strapi version: 3.6.1
  • Database: Postgres 13.2-1.pgdg100+1
  • Operating system:

Additional context

Add any other context about the problem here.

Metadata

Metadata

Assignees

Labels

issue: quick fixIssues that could be fixed quickly, with small- to medium-sized PRspr: fixUsed on the docs repo for anything that is not "new" or "updated" content: chore, typos, fixes, etc.severity: mediumIf it breaks the basic use of the product but can be worked aroundsource: Dev DocsPRs/issues targeting the Developer Docsstatus: confirmedConfirmed by a Strapi Team member or multiple community memberstarget: v3Documentation PRs/issues targeting content from docs-v3.strapi.io (v3 branch)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions