[BUG] Immich-machine-learning can't connect to postgres unix socket #329

Closed
opened 2026-02-04 19:43:11 +03:00 by OVERLORD · 0 comments
Owner

Originally created by @JVT038 on GitHub (Sep 23, 2022).

Describe the bug
The machine learning image can't connect to my postgres database with Unix sockets.

Task List

Please complete the task list below. We need this information to help us reproduce the bug or point out problems in your setup. You are not providing enough info may delay our effort to help you.

  • I have read thoroughly the README setup and installation instructions.
  • I have included my docker-compose file.
  • I have included my redacted .env file.
  • I have included information on my machine, and environment.

To Reproduce
Steps to reproduce the behavior:

  1. Make sure Postgres is accessed with unix sockets
  2. Start machine learning image
  3. docker-compose logs -f immich-machine-learning
  4. See error

Expected behavior
I expected the machine learning image to function as usual

System

  • Phone OS [iOS, Android]: Android 11
  • Server Version: v1.29.5
  • Mobile App Version: 1.29.1

Additional context
I have made a custom build of the machine learning image, so Tensorflow works without the AVX instruction set. I successfully followed the instructions at https://github.com/immich-app/immich/discussions/300.

My docker-compose, especially the machine-learning and database part:

  immich-machine-learning:
    build:
      context: $DOCKERDIR/immich/immich-ml
      dockerfile: Dockerfile
    entrypoint: ["/bin/sh", "./entrypoint.sh"]
    volumes:
      - ${UPLOAD_LOCATION}:/usr/src/app/upload
    env_file:
      - .env
    environment:
      - NODE_ENV=production
    depends_on:
      - database
    restart: always

  database:
    container_name: immich_postgres
    image: postgres:14-bullseye
    user: $PUID:$PGID
    command: postgres -c unix_socket_directories='/var/run/postgresql/,/sockets/'
    env_file:
      - .env
    environment:
      POSTGRES_PASSWORD: ${DB_PASSWORD}
      POSTGRES_USER: ${DB_USERNAME}
      POSTGRES_DB: ${DB_DATABASE_NAME}
      PG_DATA: /var/lib/postgresql/data
      PGPORT: ${DB_PORT}
    volumes:
      - $DOCKERDIR/immich/pgdata:/var/lib/postgresql/data
      - sockets:/sockets
    restart: always

The relevant part of my .env file:

DB_HOSTNAME=/sockets
DB_USERNAME=postgres
DB_PASSWORD=postgres
DB_DATABASE_NAME=immich
DB_PORT=5433

All other containers can correctly access the postgres database, except for the machine learning container.
The machine-learning image shows this error in the docker logs:

immich-machine-learning_1  | [Nest] 7  - 09/23/2022, 4:26:21 PM   ERROR [TypeOrmModule] Unable to connect to the database. Retrying (6)...
immich-machine-learning_1  | Error: connect ENOENT /sockets/.s.PGSQL.5433
immich-machine-learning_1  |     at PipeConnectWrap.afterConnect [as oncomplete] (node:net:1247:16)
Originally created by @JVT038 on GitHub (Sep 23, 2022). **Describe the bug** The machine learning image can't connect to my postgres database with Unix sockets. **Task List** *Please complete the task list below. We need this information to help us reproduce the bug or point out problems in your setup. You are not providing enough info may delay our effort to help you.* - [x] I have read thoroughly the README setup and installation instructions. - [x] I have included my `docker-compose` file. - [x] I have included my redacted `.env` file. - [x] I have included information on my machine, and environment. **To Reproduce** Steps to reproduce the behavior: 1. Make sure Postgres is accessed with unix sockets 2. Start machine learning image 3. `docker-compose logs -f immich-machine-learning` 4. See error **Expected behavior** I expected the machine learning image to function as usual **System** - Phone OS [iOS, Android]: `Android 11` - Server Version: `v1.29.5` - Mobile App Version: `1.29.1` **Additional context** I have made a custom build of the machine learning image, so Tensorflow works without the AVX instruction set. I successfully followed the instructions at https://github.com/immich-app/immich/discussions/300. My docker-compose, especially the machine-learning and database part: ```compose immich-machine-learning: build: context: $DOCKERDIR/immich/immich-ml dockerfile: Dockerfile entrypoint: ["/bin/sh", "./entrypoint.sh"] volumes: - ${UPLOAD_LOCATION}:/usr/src/app/upload env_file: - .env environment: - NODE_ENV=production depends_on: - database restart: always database: container_name: immich_postgres image: postgres:14-bullseye user: $PUID:$PGID command: postgres -c unix_socket_directories='/var/run/postgresql/,/sockets/' env_file: - .env environment: POSTGRES_PASSWORD: ${DB_PASSWORD} POSTGRES_USER: ${DB_USERNAME} POSTGRES_DB: ${DB_DATABASE_NAME} PG_DATA: /var/lib/postgresql/data PGPORT: ${DB_PORT} volumes: - $DOCKERDIR/immich/pgdata:/var/lib/postgresql/data - sockets:/sockets restart: always ``` The relevant part of my `.env` file: ``` DB_HOSTNAME=/sockets DB_USERNAME=postgres DB_PASSWORD=postgres DB_DATABASE_NAME=immich DB_PORT=5433 ``` All other containers can correctly access the postgres database, except for the machine learning container. The machine-learning image shows this error in the docker logs: ``` immich-machine-learning_1 | [Nest] 7 - 09/23/2022, 4:26:21 PM ERROR [TypeOrmModule] Unable to connect to the database. Retrying (6)... immich-machine-learning_1 | Error: connect ENOENT /sockets/.s.PGSQL.5433 immich-machine-learning_1 | at PipeConnectWrap.afterConnect [as oncomplete] (node:net:1247:16) ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: immich-app/immich#329