Closed djoylove closed 1 month ago
Hey there, @djoylove! I'm here to assist you with any bugs, questions, or contributions you have. Let's get to the bottom of this together.
I found some similar issues and discussions that might help you resolve the error "database 'postgres' does not exist":
docker-compose.yaml
file [3].To resolve the error "database 'postgres' does not exist" when setting up Dify version 0.73 on a self-hosted Docker environment, ensure that the POSTGRES_DB
environment variable is set correctly in your docker-compose.yaml
file. By default, it should be set to dify
.
Here is the relevant section of the docker-compose.yaml
file:
services:
pgvector:
image: pgvector/pgvector:pg16
restart: always
environment:
PGUSER: postgres
POSTGRES_PASSWORD: difyai123456
POSTGRES_DB: dify
PGDATA: /var/lib/postgresql/data/pgdata
volumes:
- ./volumes/pgvector/data:/var/lib/postgresql/data
ports:
- "5433:5432"
healthcheck:
test: [ "CMD", "pg_isready" ]
interval: 1s
timeout: 3s
retries: 30
Ensure that the POSTGRES_DB
environment variable is set to dify
or the name of the database you intend to use. If you need to use a different database name, update the POSTGRES_DB
variable accordingly and make sure that the database exists.
Additionally, you need to address the pg_hba.conf
entry issue. Ensure that your pg_hba.conf
file allows connections from the Docker network. You can add the following entry to your pg_hba.conf
file:
host all all 172.18.0.0/16 md5
This entry allows all hosts in the 172.18.0.0/16
subnet to connect using MD5 authentication.
After making these changes, restart your Docker containers:
Navigate to the Docker directory in the Dify source code:
cd dify/docker
Copy the environment configuration file:
cp .env.example .env
Start the Docker containers:
If you have Docker Compose V2, use the following command:
docker compose up -d
If you have Docker Compose V1, use the following command:
docker-compose up -d
After executing the command, check if all containers are running successfully:
docker compose ps
This should help you resolve the error and successfully set up Dify [4][5].
To continue talking to Dosu, mention @dosu.
您好,您的邮件我已收到,我会尽快回复你的!
Self Checks
Dify version
0.73
Cloud or Self Hosted
Self Hosted (Docker)
Steps to reproduce
i do this step on my macbook M1
cd docker cp .env.example .env docker compose up -d
than i get error
docker-db-1 | docker-db-1 | PostgreSQL Database directory appears to contain a database; Skipping initialization docker-db-1 | docker-db-1 |
docker-db-1 | 2024-09-09 08:39:54.594 UTC [1] LOG: starting PostgreSQL 15.8 on aarch64-unknown-linux-musl, compiled by gcc (Alpine 13.2.1_git20240309) 13.2.1 20240309, 64-bit docker-db-1 | 2024-09-09 08:39:54.595 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432 docker-db-1 | 2024-09-09 08:39:54.595 UTC [1] LOG: listening on IPv6 address "::", port 5432 docker-db-1 | 2024-09-09 08:39:54.606 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" docker-db-1 | 2024-09-09 08:39:54.721 UTC [37] LOG: database system was shut down at 2024-09-09 08:29:08 UTC docker-db-1 | 2024-09-09 08:39:54.794 UTC [1] LOG: database system is ready to accept connections docker-web-1 | pm2 launched in no-daemon mode (you can add DEBUG="*" env variable to get more messages)
docker-db-1 | 2024-09-09 08:39:55.421 UTC [47] FATAL: database "postgres" does not exist docker-db-1 | 2024-09-09 08:40:07.395 UTC [126] FATAL: no pg_hba.conf entry for host "172.18.0.6", user "postgres", database "dify", no encryption docker-worker-1 | ERROR [root] Database migration failed, error: (psycopg2.OperationalError) connection to server at "db" (172.18.0.5), port 5432 failed: FATAL: no pg_hba.conf entry for host "172.18.0.6", user "postgres", database "dify", no encryption
✔️ Expected Behavior
i can do http://localhost/install to setup
❌ Actual Behavior
error instead