I am trying to connect Strapi with PostgreSQL database. I am also using Docker in order to compose the “db”. I have managed to make the PostgreSQL running on port 5432, and I am also able to connect to the database with docker exec -it nameOfContainer bash
command without any problems.
The only problem I do have is that I can not connect to the database from Strapi. I keep getting error password authentication failed for user "strapibase"
. I know that the username of superuser is “strapibase” but I keep getting errors on and can not run the Strapi yarn run develop
command.
docker-compose.yml
version: '3.3'
services:
db:
image: postgres:alpine
networks:
- strapi-app-network
volumes:
- db-data:/data
ports:
- "5432:5432"
environment:
POSTGRES_DB: strapibase
POSTGRES_USER: strapibase
POSTGRES_PASSWORD: strapibase
volumes:
db-data:
networks:
strapi-app-network:
driver: bridge
database.js
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", "strapibase"),
username: env("DATABASE_USERNAME", "strapibase"),
password: env("DATABASE_PASSWORD", "strapibase"),
schema: env("DATABASE_SCHEMA", "public"),
},
options: {},
},
},
});