Connecting service directus to postgres db keeps throwing ECONNREFUSED

Hi All,
I’m running docker (24.0.6, build ed223bc) on my local Linux Mint OS
1.
The following error keeps showing during “docker-compose up” and although NOT impeditive (the server eventually starts listenning and the application goes up) one never knows how many attempts will be needed before connection succeeds. Is this normal or is there something wrong?

Error:

directus_1 | Error: connect ECONNREFUSED 192.168.48.2:5432
directus_1 | at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1555:16) {
directus_1 | errno: -111,
directus_1 | code: ‘ECONNREFUSED’,
directus_1 | syscall: ‘connect’,
directus_1 | address: ‘192.168.48.2’,
directus_1 | port: 5432
directus_1 | }

After a couple of attempts that could take sometime it eventually connects and starts responding:

directus_1 | [11:28:39.454] INFO: Server started at http://0.0.0.0:8050

-----------------------------------------YML config file ----------------------------------------------------------

Use postgres/example user/password credentials

version: ‘3.9’

services:
db:
image: kartoza/postgis:14-3.2
container_name: pg_container
volumes:
- ECO_CD:/var/lib/postgresql
- ./backup.sql:/docker-entrypoint-initdb.d/directus.sql
environment:
# If you need to create multiple database you can add coma separated databases eg gis,data
- POSTGRES_DB=directus
- POSTGRES_USER=directus
- POSTGRES_PASS=directus
- POSTGRES_MULTIPLE_EXTENSIONS=postgis,hstore,postgis_topology,postgis_raster,pgrouting
ports:
- “5432:5432”
networks:
- Ecodirectus
restart: on-failure
healthcheck:
test: “exit 0”

pgadmin:
image: dpage/pgadmin4
container_name: pgadmin4_container
restart: always
ports:
- “8888:80”
environment:
PGADMIN_DEFAULT_EMAIL: ‘myemail@myserver.com’
PGADMIN_DEFAULT_PASSWORD: ‘password’

directus:
image: directus/directus:latest
ports:
- 8050:8050
build:
context: ./DIRECTUS
dockerfile: Dockerfile
volumes:
- ./DIRECTUS/uploads:/directus/uploads
networks:
- Ecodirectus

restart: always
depends_on:
- db
#env_file:

- ./DIRECTUS/.env

environment:
KEY: ‘xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx’
SECRET: ‘yyyyyyyyyyyyyyyyyyyyyyyyy’

 DB_CLIENT: 'pg'
 DB_HOST: 'pg_container'
 DB_PORT: '5432'
 DB_DATABASE: 'directus'
 DB_USER: 'directus'
 DB_PASSWORD: 'directus'
 ADMIN_EMAIL: 'xxx@server.com'
 ADMIN_PASSWORD: 'anotherpassword'

networks:
Ecodirectus:
driver: bridge

volumes:
ECO_CD:

  1. Once server is responding, another strange thing (for me!) happens:
    From pgadmin, I am able to connect to the postgres database only via the gateway IP.
    In order to do that I list my containers (docker ps), then I inspect pg_ container which gives me the IP, docker has allocated to the service. Instead of using the IPAddress, the connection via pgadmin4 will only be established if using the Gateway at Host name/address, which always ends on 1.

                 "Gateway": "192.168.80.1",
                 "IPAddress": "192.168.80.2",