Kobo KPI Setup container doesn't recognize Postgres extra hostname correctly

I’m trying to use the python3 run.py, but it gets stuck when bringing up the KPI when trying to configure the database connection:

Removing network egh-kobofe_kobo-fe-network
Removing network egh-kobomaintenance_kobo-maintenance-network
WARNING: Network egh-kobomaintenance_kobo-maintenance-network not found.
Removing network egh-kobofe_kobo-fe-network
WARNING: Network egh-kobofe_kobo-fe-network not found.
Removing network nginx-certbot_default
WARNING: Network nginx-certbot_default not found.
Stopping egh-kobobe_postgres_1    ... done
Stopping egh-kobobe_mongo_1       ... done
Stopping egh-kobobe_redis_cache_1 ... done
Stopping egh-kobobe_redis_main_1  ... done
Removing egh-kobobe_postgres_1    ... done
Removing egh-kobobe_mongo_1       ... done
Removing egh-kobobe_redis_cache_1 ... done
Removing egh-kobobe_redis_main_1  ... done
Removing network egh-kobobe_default
Removing network egh-kobofe_kobo-fe-network
WARNING: Network egh-kobofe_kobo-fe-network not found.
Launching environment
Creating network "egh-kobobe_default" with the default driver
Creating egh-kobobe_mongo_1       ... done
Creating egh-kobobe_redis_cache_1 ... done
Creating egh-kobobe_postgres_1    ... done
Creating egh-kobobe_redis_main_1  ... done
Waiting for PostgreSQL database to be up & running...
Creating network "egh-kobofe_kobo-fe-network" with driver "bridge"
Creating egh-kobofe_kpi_run ... done

Then it freezes here for hours and it won’t generate any logs on the container whatsoever.

While debugging, I notice the hostname that should redirect to Postgres container IP, redirects to the Mongo container inside egh-kobofe_kpi_run_6292549c2463:

root@kpi:/srv/src/kpi# ping mongo.kobo.epigraphhub.private
PING mongo.kobo.epigraphhub.private (***) 56(84) bytes of data.
64 bytes from mongo.kobo.epigraphhub.private (***): icmp_seq=1 ttl=64 time=0.057 ms
64 bytes from mongo.kobo.epigraphhub.private (***): icmp_seq=2 ttl=64 time=0.030 ms
64 bytes from mongo.kobo.epigraphhub.private (***): icmp_seq=3 ttl=64 time=0.028 ms
^C
root@kpi:/srv/src/kpi# ping postgres.kobo.epigraphhub.private
PING postgres.kobo.epigraphhub.private (***) 56(84) bytes of data.
64 bytes from mongo.kobo.epigraphhub.private (***): icmp_seq=1 ttl=64 time=0.051 ms
64 bytes from mongo.kobo.epigraphhub.private (***): icmp_seq=2 ttl=64 time=0.038 ms
64 bytes from mongo.kobo.epigraphhub.private (***): icmp_seq=3 ttl=64 time=0.033 ms
64 bytes from mongo.kobo.epigraphhub.private (***): icmp_seq=4 ttl=64 time=0.027 ms

docker-compose.backend.primary.override.yml

  postgres:
    volumes:
      - ../kobo-env/postgres/primary/postgres.conf:/kobo-docker-scripts/primary/postgres.conf
    #environment:
    #  - POSTGRES_BACKUP_FROM_SECONDARY=True
    ports:
      - 5433:5432
    #networks:
    #  kobo-be-network:
    #    aliases:
    #      - postgres.kobo.epigraphhub.private

  mongo:
    ports:
      - 27017:27017
    #networks:
    #  kobo-be-network:
    #    aliases:
    #      - mongo.kobo.epigraphhub.private

docker-compose.backend.secondary.override.yaml:

services:
  postgres:
    volumes:
      - ../kobo-env/postgres/secondary/postgres.conf:/kobo-docker-scripts/secondary/postgres.conf
    ports:
      - 5433:5432
    extra_hosts:
      - postgres.kobo.epigraphhub.private:***
      - primary.postgres.kobo.epigraphhub.private:***

Although python3 run.py won’t generate any log at all, I could reproduce the error inside container once and confirmed the error (this screenshot is from another config, thats why the hostname appears postgres.epigraphhub.private and not postgres.kobo.epigraphhub.private, but the error is the same):

PS: *** is the same IP number to all occurrences (the remote server’s IP)