Edit: I found the solution. I was missing a few environment variables.
These are the functioning Ansible tasks to deploy Immich:
- name: create Immich network
community.docker.docker_network:
name: immich-network
state: present
- name: deploy Immich-Redis
community.docker.docker_container:
name: immich-redis
image: registry.hub.docker.com/library/redis:6.2-alpine@sha256:84882e87b54734154586e5f8abd4dce69fe7311315e2fc6d67c29614c8de2672
restart_policy: always
networks:
- name: immich-network
- name: deploy Immich-Postgres
community.docker.docker_container:
name: immich-postgres
image: registry.hub.docker.com/tensorchord/pgvecto-rs:pg14-v0.2.0@sha256:90724186f0a3517cf6914295b5ab410db9ce23190a2d9d0b9dd6463e3fa298f0
restart_policy: always
volumes:
- "{{ nvme_mount_point }}/immich/postgres:/var/lib/postgresql/data"
env:
POSTGRES_DB: "{{ immich_postgres_db_name }}"
POSTGRES_USER: "{{ immich_postgres_db_user }}"
POSTGRES_PASSWORD: "{{ immich_postgres_db_password }}"
networks:
- name: immich-network
- name: deploy Immich-Machine-Learning
community.docker.docker_container:
name: immich-machine-learning
image: ghcr.io/immich-app/immich-machine-learning:release
restart_policy: always
volumes:
- "{{ nvme_mount_point }}/immich/model-cache:/cache"
networks:
- name: immich-network
env:
DB_DATABASE_NAME: "{{ immich_postgres_db_name }}"
DB_USERNAME: "{{ immich_postgres_db_user }}"
DB_PASSWORD: "{{ immich_postgres_db_password }}"
DB_DATA_LOCATION: "{{ nvme_mount_point }}/immich/postgres"
DB_HOSTNAME: immich-postgres
REDIS_HOSTNAME: immich-redis
- name: deploy Immich-Microservices
community.docker.docker_container:
name: immich-microservices
image: ghcr.io/immich-app/immich-server:release
restart_policy: always
command: ['start.sh', 'microservices']
volumes:
- "{{ hdd_mount_point}}/immich/library:/usr/src/app/upload"
- /etc/localtime:/etc/localtime:ro
networks:
- name: immich-network
env:
DB_DATABASE_NAME: "{{ immich_postgres_db_name }}"
DB_USERNAME: "{{ immich_postgres_db_user }}"
DB_PASSWORD: "{{ immich_postgres_db_password }}"
DB_DATA_LOCATION: "{{ nvme_mount_point }}/immich/postgres"
DB_HOSTNAME: immich-postgres
REDIS_HOSTNAME: immich-redis
- name: deploy Immich-Server
community.docker.docker_container:
name: immich-server
image: ghcr.io/immich-app/immich-server:release
restart_policy: always
command: ['start.sh', 'immich']
volumes:
- "{{ hdd_mount_point}}/immich/library:/usr/src/app/upload"
- /etc/localtime:/etc/localtime:ro
ports:
- "2283:3001"
networks:
- name: immich-network
env:
DB_DATABASE_NAME: "{{ immich_postgres_db_name }}"
DB_USERNAME: "{{ immich_postgres_db_user }}"
DB_PASSWORD: "{{ immich_postgres_db_password }}"
DB_DATA_LOCATION: "{{ nvme_mount_point }}/immich/postgres"
DB_HOSTNAME: immich-postgres
REDIS_HOSTNAME: immich-redis
I’m trying to install Immich via Ansible and so far so good. The containers are all running and as long as I don’t try to access it the logs all look fine but as soon as I try to access the GUI I get the following error spammed in the immich-server container log and the browser just shows a timeout and doesn’t connect to the GUI.
[Nest] 7 - 05/02/2024, 9:20:45 AM ERROR [TypeOrmModule] Unable to connect to the database. Retrying (5)...
Error: Connection terminated due to connection timeout
at Connection.<anonymous> (/usr/src/app/node_modules/pg/lib/client.js:132:73)
at Object.onceWrapper (node:events:632:28)
at Connection.emit (node:events:518:28)
at Socket.<anonymous> (/usr/src/app/node_modules/pg/lib/connection.js:63:12)
at Socket.emit (node:events:518:28)
at TCP.<anonymous> (node:net:337:12)
Error: connect ETIMEDOUT
at Socket.<anonymous> (/usr/src/app/node_modules/ioredis/built/Redis.js:170:41)
at Object.onceWrapper (node:events:632:28)
at Socket.emit (node:events:518:28)
at Socket._onTimeout (node:net:589:8)
at listOnTimeout (node:internal/timers:573:17)
at process.processTimers (node:internal/timers:514:7) {
errorno: 'ETIMEDOUT',
code: 'ETIMEDOUT',
syscall: 'connect'
}
Here are my Ansible tasks to deploy Immich:
- name: create Immich network
community.docker.docker_network:
name: immich-network
state: present
- name: deploy Immich-Redis
community.docker.docker_container:
name: immich-redis
image: registry.hub.docker.com/library/redis:6.2-alpine@sha256:84882e87b54734154586e5f8abd4dce69fe7311315e2fc6d67c29614c8de2672
restart_policy: always
networks:
- name: immich-network
- name: deploy Immich-Postgres
community.docker.docker_container:
name: immich-postgres
image: registry.hub.docker.com/tensorchord/pgvecto-rs:pg14-v0.2.0@sha256:90724186f0a3517cf6914295b5ab410db9ce23190a2d9d0b9dd6463e3fa298f0
restart_policy: always
volumes:
- "{{ nvme_mount_point }}/immich/postgres:/var/lib/postgresql/data"
env:
POSTGRES_DB: "{{ immich_postgres_db_name }}"
POSTGRES_USER: "{{ immich_postgres_db_user }}"
POSTGRES_PASSWORD: "{{ immich_postgres_db_password }}"
networks:
- name: immich-network
- name: deploy Immich-Machine-Learning
community.docker.docker_container:
name: immich-machine-learning
image: ghcr.io/immich-app/immich-machine-learning:release
restart_policy: always
volumes:
- "{{ nvme_mount_point }}/immich/model-cache:/cache"
networks:
- name: immich-network
env:
DB_DATABASE_NAME: "{{ immich_postgres_db_name }}"
DB_USERNAME: "{{ immich_postgres_db_user }}"
DB_PASSWORD: "{{ immich_postgres_db_password }}"
- name: deploy Immich-Microservices
community.docker.docker_container:
name: immich-microservices
image: ghcr.io/immich-app/immich-server:release
restart_policy: always
command: ['start.sh', 'microservices']
volumes:
- "{{ hdd_mount_point}}/immich/library:/usr/src/app/upload"
- /etc/localtime:/etc/localtime
networks:
- name: immich-network
env:
DB_DATABASE_NAME: "{{ immich_postgres_db_name }}"
DB_USERNAME: "{{ immich_postgres_db_user }}"
DB_PASSWORD: "{{ immich_postgres_db_password }}"
- name: deploy Immich-Server
community.docker.docker_container:
name: immich-server
image: ghcr.io/immich-app/immich-server:release
restart_policy: always
command: ['start.sh', 'immich']
volumes:
- "{{ hdd_mount_point}}/immich/library:/usr/src/app/upload"
- /etc/localtime:/etc/localtime
ports:
- "2283:3001"
networks:
- name: immich-network
env:
DB_DATABASE_NAME: "{{ immich_postgres_db_name }}"
DB_USERNAME: "{{ immich_postgres_db_user }}"
DB_PASSWORD: "{{ immich_postgres_db_password }}"
The variables are:
immich_postgres_db_name: immich
immich_postgres_db_user: postgres
immich_postgres_db_password: postgres
for testing purposes.
I’m currently running this on a Hyper-V VM running Fedora 39 Server Edition.
I don’t know how to fix this issue, can someone help me?
I found this issue on the Immich GitHub where I found a possible fix regarding the firewall that it might block something but it didn’t really help.
So I’m thankful for any ideas you can throw my way. Tell me if you need any more info.
Edit: Overlooked an error in the log and added it to the post.
A place to share alternatives to popular online services that can be self-hosted without giving up privacy or locking you into a service you don’t control.
Rules:
Be civil: we’re here to support and learn from one another. Insults won’t be tolerated. Flame wars are frowned upon.
No spam posting.
Posts have to be centered around self-hosting. There are other communities for discussing hardware or home computing. If it’s not obvious why your post topic revolves around selfhosting, please include details to make it clear.
Don’t duplicate the full text of your blog or github here. Just post the link for folks to click.
Submission headline should match the article title (don’t cherry-pick information from the title to fit your agenda).
No trolling.
Resources:
Any issues on the community? Report it using the report flag.
Questions? DM the mods!
I think you have forgotten to specify the hostname of your database. Immich has the credentials to the database but doesn’t know where it is.
The environment variable would be
DB_HOSTNAME
.Edit: I just noticed the other error message regarding Redis, and I suspect the same mistake there, you need to specify
REDIS_HOSTNAME
.This confuses me because the default docker-compose.yml from Immich doesn’t set these environment variables.
That confuses me as well, I guess they changed docs in meantime. Anyway, here is my working env:
Seems like they changed it last week: https://github.com/immich-app/immich/commit/7ea539b753b1993cd0735db408e5954288bf6b68
I added the
REDIS_HOSTNAME
andDB_DATA_LOCATION
environment variables. Not sure if I understood it right, but I guess not since it still doesn’t work:Ansible tasks
This is what I have now and I get the following error in immich-server and immich-microservices:
Edit: It works! I forgot to add DB_HOSTNAME