Immich can't connect to postgres #2159

Closed
opened 2026-02-05 05:21:36 +03:00 by OVERLORD · 0 comments
Owner

Originally created by @OddMagnet on GitHub (Feb 12, 2024).

The bug

I get the following error when starting up my containers:
Error: connect ECONNREFUSED 127.0.0.1:5432 at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1595:16)
Both the server and microservices components have this problem.

The OS that Immich Server is running on

Unraid 6.12.6

Version of Immich Server

v1.94.1

Version of Immich Mobile App

Platform with the issue

  • Server
  • Web
  • Mobile

Your docker-compose.yml content

networks:
  default:
    name: my-network
    external: false

services:
  immich-server:
    container_name: immich-server
    image: ghcr.io/immich-app/immich-server:${IMMICH_VERSION}
    restart: unless-stopped
    command: [ "start.sh", "immich" ]
    ports:
      - 2283:3001
    depends_on:
      - immich_redis
      - immich_postgres
    volumes:
      - ${PHOTO_DIR}:/usr/src/app/upload
      - /etc/localtime:/etc/localtime:ro
    environment:
      - DB_DATABASE_NAME=${POSTGRES_IMMICH_DB}
      - DB_USERNAME=${POSTGRES_IMMICH_USER}
      - DB_PASSWORD=${POSTGRES_IMMICH_PW}

  immich-microservices:
    container_name: immich-microservices
    image: ghcr.io/immich-app/immich-server:${IMMICH_VERSION}
    extends:
      file: immich/hwaccel.transcoding.yml 
      service: quicksync
    command: [ "start.sh", "microservices" ]
    restart: unless-stopped
    depends_on:
      - immich_redis
      - immich_postgres
    volumes:
      - ${PHOTO_DIR}:/usr/src/app/upload
      - /etc/localtime:/etc/localtime:ro
    environment:
      - DB_DATABASE_NAME=${POSTGRES_IMMICH_DB}
      - DB_USERNAME=${POSTGRES_IMMICH_USER}
      - DB_PASSWORD=${POSTGRES_IMMICH_PW}

  immich-machine-learning:
    container_name: immich-machine-learning
    image: ghcr.io/immich-app/immich-machine-learning:${IMMICH_VERSION}-${IMMICH_HW_ACCEL_TAG}
    extends:
      file: immich/hwaccel.ml.yml
      service: ${IMMICH_HW_ACCEL_TAG}
    restart: unless-stopped
    volumes:
      - ${CONFIG_DIR}/immich/cache:/cache

  immich_redis:
    container_name: immich-redis
    image: redis:6.2-alpine@sha256:afb290a0a0d0b2bd7537b62ebff1eb84d045c757c1c31ca2ca48c79536c0de82
    restart: unless-stopped

  immich_postgres:
    container_name: immich-postgres
    image: tensorchord/pgvecto-rs:pg14-v0.1.11@sha256:0335a1a22f8c5dd1b697f14f079934f5152eaaa216c09b61e293be285491f8ee
    restart: unless-stopped
    volumes:
      - ${CONFIG_DIR}/immich/data:/var/lib/postgresql/data
    environment:
      - POSTGRES_DB=${POSTGRES_IMMICH_DB}
      - POSTGRES_USER=${POSTGRES_IMMICH_USER}
      - POSTGRES_PASSWORD=${POSTGRES_IMMICH_PW}

Your .env content

CONFIG_DIR=/usr/mnt/appdata
PHOTO_DIR=/usr/mnt/data/photos

IMMICH_VERSION=v1.94.1
IMMICH_HW_ACCEL_TAG=openvino
POSTGRES_IMMICH_DB=postgres-immich
POSTGRES_IMMICH_USER=immich
POSTGRES_IMMICH_PW=super-secure-password-for-reals

Reproduction steps

1. docker compose up
2. observe logs

Additional information

I verified that the database name, user name and password are correct by doing the following:

> user@Unraid: docker exec -it immich-postgres sh
# psql -U immich -d postgres-immich
postgres-immich=# \l
                                 List of databases
      Name       | Owner  | Encoding |  Collate   |   Ctype    | Access privileges
-----------------+--------+----------+------------+------------+-------------------
 postgres        | immich | UTF8     | en_US.utf8 | en_US.utf8 |
 postgres-immich | immich | UTF8     | en_US.utf8 | en_US.utf8 |
 template0       | immich | UTF8     | en_US.utf8 | en_US.utf8 | =c/immich        +
                 |        |          |            |            | immich=CTc/immich
 template1       | immich | UTF8     | en_US.utf8 | en_US.utf8 | =c/immich        +
                 |        |          |            |            | immich=CTc/immich
postgres-immich=# \c postgres-immich
You are now connected to database "postgres-immich" as user "immich".
Originally created by @OddMagnet on GitHub (Feb 12, 2024). ### The bug I get the following error when starting up my containers: `Error: connect ECONNREFUSED 127.0.0.1:5432 at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1595:16)` Both the server and microservices components have this problem. ### The OS that Immich Server is running on Unraid 6.12.6 ### Version of Immich Server v1.94.1 ### Version of Immich Mobile App - ### Platform with the issue - [X] Server - [X] Web - [ ] Mobile ### Your docker-compose.yml content ```YAML networks: default: name: my-network external: false services: immich-server: container_name: immich-server image: ghcr.io/immich-app/immich-server:${IMMICH_VERSION} restart: unless-stopped command: [ "start.sh", "immich" ] ports: - 2283:3001 depends_on: - immich_redis - immich_postgres volumes: - ${PHOTO_DIR}:/usr/src/app/upload - /etc/localtime:/etc/localtime:ro environment: - DB_DATABASE_NAME=${POSTGRES_IMMICH_DB} - DB_USERNAME=${POSTGRES_IMMICH_USER} - DB_PASSWORD=${POSTGRES_IMMICH_PW} immich-microservices: container_name: immich-microservices image: ghcr.io/immich-app/immich-server:${IMMICH_VERSION} extends: file: immich/hwaccel.transcoding.yml service: quicksync command: [ "start.sh", "microservices" ] restart: unless-stopped depends_on: - immich_redis - immich_postgres volumes: - ${PHOTO_DIR}:/usr/src/app/upload - /etc/localtime:/etc/localtime:ro environment: - DB_DATABASE_NAME=${POSTGRES_IMMICH_DB} - DB_USERNAME=${POSTGRES_IMMICH_USER} - DB_PASSWORD=${POSTGRES_IMMICH_PW} immich-machine-learning: container_name: immich-machine-learning image: ghcr.io/immich-app/immich-machine-learning:${IMMICH_VERSION}-${IMMICH_HW_ACCEL_TAG} extends: file: immich/hwaccel.ml.yml service: ${IMMICH_HW_ACCEL_TAG} restart: unless-stopped volumes: - ${CONFIG_DIR}/immich/cache:/cache immich_redis: container_name: immich-redis image: redis:6.2-alpine@sha256:afb290a0a0d0b2bd7537b62ebff1eb84d045c757c1c31ca2ca48c79536c0de82 restart: unless-stopped immich_postgres: container_name: immich-postgres image: tensorchord/pgvecto-rs:pg14-v0.1.11@sha256:0335a1a22f8c5dd1b697f14f079934f5152eaaa216c09b61e293be285491f8ee restart: unless-stopped volumes: - ${CONFIG_DIR}/immich/data:/var/lib/postgresql/data environment: - POSTGRES_DB=${POSTGRES_IMMICH_DB} - POSTGRES_USER=${POSTGRES_IMMICH_USER} - POSTGRES_PASSWORD=${POSTGRES_IMMICH_PW} ``` ### Your .env content ```Shell CONFIG_DIR=/usr/mnt/appdata PHOTO_DIR=/usr/mnt/data/photos IMMICH_VERSION=v1.94.1 IMMICH_HW_ACCEL_TAG=openvino POSTGRES_IMMICH_DB=postgres-immich POSTGRES_IMMICH_USER=immich POSTGRES_IMMICH_PW=super-secure-password-for-reals ``` ### Reproduction steps ```bash 1. docker compose up 2. observe logs ``` ### Additional information I verified that the database name, user name and password are correct by doing the following: ``` > user@Unraid: docker exec -it immich-postgres sh # psql -U immich -d postgres-immich postgres-immich=# \l List of databases Name | Owner | Encoding | Collate | Ctype | Access privileges -----------------+--------+----------+------------+------------+------------------- postgres | immich | UTF8 | en_US.utf8 | en_US.utf8 | postgres-immich | immich | UTF8 | en_US.utf8 | en_US.utf8 | template0 | immich | UTF8 | en_US.utf8 | en_US.utf8 | =c/immich + | | | | | immich=CTc/immich template1 | immich | UTF8 | en_US.utf8 | en_US.utf8 | =c/immich + | | | | | immich=CTc/immich postgres-immich=# \c postgres-immich You are now connected to database "postgres-immich" as user "immich". ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: immich-app/immich#2159