dockercitus

Unable to connect to CitusData - SQLSTATE[08006] error


I am getting an issue with CitusData docker version on MAC.

SQLSTATE[08006] [7] could not connect to server: Connection refused 

List of docker containers below:

ba187040a5ca        citusdata/citus:8.2.2                "docker-entrypoint.s…"   About a minute ago   Up About a minute (healthy)   5432/tcp                                   citus_worker_1
3105ddb06049        citusdata/membership-manager:0.2.0   "python -u ./manager…"   About a minute ago   Up About a minute (healthy)                                              citus_manager
2cbd2b2bad49        citusdata/citus:8.2.2                "docker-entrypoint.s…"   About a minute ago   Up About a minute (healthy)   0.0.0.0:5433->5432/tcp                     citus_master

docker-compose.yml - https://docs.citusdata.com/en/stable/installation/single_machine_docker.html#post-install version: '2.1'

services:
  master:
    container_name: "${COMPOSE_PROJECT_NAME:-citus}_master"
    image: 'citusdata/citus:8.2.2'
    ports: ["${MASTER_EXTERNAL_PORT:-5432}:5432"]
    labels: ['com.citusdata.role=Master']
  worker:
    image: 'citusdata/citus:8.2.2'
    labels: ['com.citusdata.role=Worker']
    depends_on: { manager: { condition: service_healthy } }
  manager:
    container_name: "${COMPOSE_PROJECT_NAME:-citus}_manager"
    image: 'citusdata/membership-manager:0.2.0'
    volumes: ['/var/run/docker.sock:/var/run/docker.sock']
    depends_on: { master: { condition: service_healthy } }

Solution

  • The 5433 port seems to be the problem in master container. 0.0.0.0:5433->5432/tcp. PostgreSQL uses 5432 port by default, and this seems to be the reason why the connection is refused.

    Did you change the default port mapping in docker-compose.yml? Maybe you set MASTER_EXTERNAL_PORT=5433 and forgot to use that when trying to reach citus database.

    If you wish to continue using 5433 port, you can use psql -U postgres -h localhost -p 5433 to connect to the database.