org.postgresql.util.PSQLException: Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections." . Mong mọi người chỉ em cách giải quyết ạ .Em cảm ơn .
org.postgresql.util.PSQLException: Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections." . Mong mọi người chỉ em cách giải quyết ạ .Em cảm ơn .
Em có thể share file Dockerfile được không em?
version: "3.7"
services:
database:
image: postgres
restart: always
env_file:
- .env
ports:
- "5432:5432"
volumes:
- data:/var/lib/postgresql/data
server:
depends_on:
- database
build:
context: .
dockerfile: Dockerfile
environment:
DB_HOST: database
DB_PORT: 3306
DB_USER: root
DB_PASSWORD: mauFJcuf5dhRMQrjj
DB_NAME: quotes
networks:
- default
ports:
- "8080:8080"
volumes:
data:
Để ý có 2 service là "database" và "server", trong đó server sẽ start sau database, và kết nối đến db thông qua biến môi trường là DB_HOST: database