authentik icon indicating copy to clipboard operation
authentik copied to clipboard

PostgreSQL connection failure with IPv6?

Open williamkray opened this issue 1 year ago • 1 comments

Describe your question/ i am attempting to stand up the authentik stack within an existing docker-compose environment, as such i'm not following the provided docker-compose.yaml exactly.

when i start the authentik server, it spits out the following error repeatedly:

{"event": "PostgreSQL connection failed, retrying... (connection is bad: connection to server at \"::1\", port 5432 failed: Cannot assign requested address\n\tIs the server running on that host and accepting TCP/IP connections?)", "level": "info", "logger": "authentik.lib.config", "timestamp": 1725920878.1804812}

i have authentik-server, authentik-worker, redis, and postgresql connected to a shared docker network called authentik. the database has a network alias of database, and the redis instance has a network alias of redis (very creative).

i am able to nc to the database on port 5432 from the redis container, and similar vice versa, so i know the docker network is connecting the two properly, AND i'm able to do an nslookup from the postgres container and it returns the IP address of my authentik server container, however it seems that the authentik container image (used for both the server and worker) are unable to get to either despite also being on the same network, and the fact that the error says it's failing when connecting to server at ::1 seems suspicious.

i don't have anything fancy in my docker daemon.json file other than using local log-driver.

Version and Deployment (please complete the following information):

  • authentik version: 2024.8.1
  • Deployment: docker compose

williamkray avatar Sep 09 '24 22:09 williamkray

a significantly truncated version of my docker-compose (only relevant bits):

networks:
  authentik:
  public:

services:
    authentik-psql:
    image: docker.io/library/postgres:16-alpine
    restart: unless-stopped
    networks:
      authentik:
        aliases:
          - database
    expose:
      - 5432
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -d authentik -U authentik"]
      start_period: 20s
      interval: 30s
      retries: 5
      timeout: 5s
    volumes:
      - ./storage/authentik/psql:/var/lib/postgresql/data
    environment:
      <stuff>

  authentik-server:
    image: ghcr.io/goauthentik/server:2024.8.1
    restart: unless-stopped
    command: server
    networks:
      authentik:
        aliases:
          - server
      public:
        aliases:
          - authentik-server
    volumes:
      - ./storage/authentik/media:/media
      - ./storage/authentik/custom-templates:/templates
    environment:
      <stuff>

only pretend it doesn't have spacing issues and is valid yaml.

williamkray avatar Sep 09 '24 22:09 williamkray

ugh nevermind, i looked with fresh eyes and saw a typo in my env variables. sorry for the noise.

williamkray avatar Sep 10 '24 20:09 williamkray