I have installed PostgreSql on my machine which I want to use as external DB for the Dockerized Laravel Web app. I do not want to use the postgre image, but the local DB. It can be mysql as well.
docker-compose.yml
`version: ‘3’
services:
app:
build:
context: .
dockerfile: .docker/Dockerfile
image: docker-app
ports:
- 8004:80`
.env
`DB_CONNECTION=pgsql
DB_HOST= 127.0.0.1 or localhost
DB_PORT=5432
DB_DATABASE=testdb
DB_USERNAME=postgres
DB_PASSWORD=password`
Error is given below:
SQLSTATE[08006] [7] could not connect to server: Connection refused
Is the server running on host “127.0.0.1” and accepting TCP/IP connections on port 5432?`
The reason of the issue I know the application container is not connecting to the external DB as it is outside of its filesystem.
If I change the DB_HOST to the local IP Address, there comes up this
error:SQLSTATE[08006] [7] FATAL: no pg_hba.conf entry for host 10.0.9.57`