photonixapp/photonix

Can't connect to postgres container (Synology)

mcwieger opened this issue · 8 comments

I'm trying to install Photonix with the following docker-compose.yml:

version: '3'

services:
  postgres:
    container_name: photonix-postgres
    image: postgres:11.1-alpine
    environment:
      POSTGRES_DB: photonix
      POSTGRES_PASSWORD: password
    volumes:
      - /volume1/docker/photonix/data/db:/var/lib/postgresql/data

  redis:
    container_name: photonix-redis
    image: redis:6.2.2

  photonix:
    container_name: photonix
    image: photonixapp/photonix:latest
    ports:
      - '8888:80'
    environment:
      ENV: prd
      POSTGRES_HOST: postgres
      POSTGRES_DB: photonix
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: password
      REDIS_HOST: redis
      ALLOWED_HOSTS: '*'
      ADMIN_USERNAME: user
      ADMIN_PASSWORD: 'password'
      # More configuration options here: https://photonix.org/docs/configuration/
    volumes:
      - /volume1/docker/photonix/data/photos:/data/photos
      - /volume1/docker/photonix/data/raw-photos-processed:/data/raw-photos-processed
      - /volume1/docker/photonix/data/cache:/data/cache
      - /volume1/docker/photonix/data/models:/data/models
    links:
      - postgres
      - redis

All three containers are up, but photonix can't seem to connect to the postgres server. The log says:

2021-08-18 15:26:58 | stderr | Postgres is unavailable - sleeping
2021-08-18 15:26:58 | stderr | postgres [172.20.0.2] 5432 (postgresql) : Connection timed out

Very limited info, but any idea what could be the issue?

It looks like other Redis/Postgres containers where the issue. I had to remove those to be able to start.

It's connecting to postgres/redis now and connecting on :8888.

However, when logging in, it keeps loading and I can't actually log in.

Log says:

021-08-19 10:06:14 | stderr | DNS fwd/rev mismatch: postgres != photonix-postgres.photonix_default
2021-08-19 10:06:13 | stderr | Postgres is unavailable - sleeping
2021-08-19 10:06:13 | stderr | postgres [172.20.0.2] 5432 (postgresql) : Connection timed out

And the logs for postgres:

2021-08-19 12:15:54 | stderr | 2021-08-19 12:15:54.634 UTC [1] LOG:  database system is ready to accept connections
2021-08-19 12:15:54 | stderr | 2021-08-19 12:15:54.433 UTC [19] LOG:  database system was shut down at 2021-08-19 12:15:13 UTC
2021-08-19 12:15:53 | stderr | 2021-08-19 12:15:53.612 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2021-08-19 12:15:53 | stderr | 2021-08-19 12:15:53.030 UTC [1] LOG:  listening on IPv6 address "::", port 5432
2021-08-19 12:15:53 | stderr | 2021-08-19 12:15:53.030 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432

And redis:

2021-08-19 12:15:53	stdout	1:M 19 Aug 2021 12:15:53.951 * Ready to accept connections
2021-08-19 12:15:53	stdout	1:M 19 Aug 2021 12:15:53.951 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
2021-08-19 12:15:53	stdout	1:M 19 Aug 2021 12:15:53.951 # Server initialized
2021-08-19 12:15:53	stdout	1:M 19 Aug 2021 12:15:53.951 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
2021-08-19 12:15:53	stdout	1:M 19 Aug 2021 12:15:53.951 * Running mode=standalone, port=6379.
2021-08-19 12:15:53	stdout	1:M 19 Aug 2021 12:15:53.950 * monotonic clock: POSIX clock_gettime
2021-08-19 12:15:53	stdout	1:C 19 Aug 2021 12:15:53.950 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
2021-08-19 12:15:53	stdout	1:C 19 Aug 2021 12:15:53.950 # Redis version=6.2.2, bits=64, commit=00000000, modified=0, pid=1, just started
2021-08-19 12:15:53	stdout	1:C 19 Aug 2021 12:15:53.950 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo

I tried making explicit references to ports (5433:5432 and 6380:6379), but that didn't help.

Ok, figured out that Synology has an internal postgres database running, that claims port 5432. I've tried using a different port in Docker compose, but the Photonix container doesn't seem to pick up the alternative port. How to connect to the database?

Same issue here

Found the solution: it was the firewall rules blocking the access. Create rule to allow the docker ip range (172.x.x.x) and you're all set!

That's great @mcwieger. Thanks for persisting and reporting back. I'm sure it will help other Synology users in the future.

Was so excited to see this post, thinking this would fix my chronic "Failed to retrieve tasks. Database unreachable." errors I'm having on my Synology Docker containers between an app Tubesync and Postgres, but sadly it did not. It simply won't find the database. :-(