[solved] Immich crash and backup restore fails / update: db auth fails

What type of hardware are you using: Old laptop or computer
What YunoHost version are you running: 12.0.14
What app is this about: Immich

Describe your issue

While using Immich the app crashed and I had 502 nginx error page.
I tried relaunching the service but it didn’t stay up. I looked at the log from the service. I lost it later but it said something about a missing plugin to handle some format.
Then I probably shouldn’t have but I tried upgrading the app. It was 1.132.1 and it would upgrade to 1.132.3
The upgrade failed and the app was uninstalled in the process. This is where I lost the previous logs. It may be in pre-upgrade log but I can’t find it.
So I wanted to restore the app from the backup three times and it failed each time, those are the logs I pasted. I rebooted several times at different times in the process and it did not make much of a difference.

I thought of upgrading yunohost in general, thinking it may fix stuff but it seems hazardous at this point. Also I could try re-install it from scratch and restore data only but I am not sure how to do that properly.

What would you advise to get back a functional Immich app? I guess I should have been more careful earlier. Thanks for any help you could bring

Share relevant logs or error messages

https://paste.yunohost.org/raw/defoqudexe
https://paste.yunohost.org/raw/eqogugipic
https://paste.yunohost.org/raw/uhuvilinef

Just backup /home/yunohost.app/immich folder and try to reinstall

Thanks for the confidence, I didn’t quite dare. However it did not work and I had this new log : https://paste.yunohost.org/raw/azavazogif
It failed somewhere in python modules on a new fresh install, twice and I rebooted in between

I eventually could reinstall immich from scratch. I managed to restore the files as you said and the db by mixing up Backup and Restore | Immich and postgre commands here Immich - 502 Bad Gateway #2 - #10 by namron : gunzip --stdout ../yunohost.app/immich/backups/immich-db-backup-1746921600012.sql.gz | sed "s/SELECT pg_catalog.set_config('search_path', '', false);/SELECT pg_catalog.set_config('search_path', 'public, pg_catalog', true);/g" | sudo --login --user=immich PGUSER=immich PGPASSWORD=<pwd> psql --cluster=16/main
Now I get 502 with this error in immich-server logs :

e[32m[Nest] 4749  - e[39m15/05/2025 02:03:27 e[32m    LOGe[39m e[33m[Microservices:EventRepository]e[39m e[32mInitialized websocket servere[39m
microservices worker error: PostgresError: authentification par mot de passe échouée pour l'utilisateur  « immich », stack: PostgresError: authentification par mot de passe échouée pour l'utilisateur  « immich »
    at ErrorResponse (/var/www/immich/app/node_modules/postgres/cjs/src/connection.js:790:26)
    at handle (/var/www/immich/app/node_modules/postgres/cjs/src/connection.js:476:6)
    at Socket.data (/var/www/immich/app/node_modules/postgres/cjs/src/connection.js:315:9)
    at Socket.emit (node:events:524:28)
    at addChunk (node:internal/streams/readable:561:12)
    at readableAddChunkPushByteMode (node:internal/streams/readable:512:3)
    at Readable.push (node:internal/streams/readable:392:5)
    at TCP.onStreamRead (node:internal/stream_base_commons:189:23)
microservices worker exited with code 1
Killing api process
Starting api worker
Starting microservices worker

So the authentication fails but the password in /var/www/immich/env is one I can manually use to connect to db. I am worried that is has something to do with --cluster=16/main since I can’t connect to db without it. If the server does not use it, I don’t know what to do to fix the situation

Edit : I do believe it’s a story of clusters because in postgre services I see

-- Boot 79d81aeb84b9477b86d657ab908b9829 --
mai 15 02:18:17 systemd[1]: Starting postgresql@15-main.service - PostgreSQL Cluster 15-main...
mai 15 02:18:53 systemd[1]: Started postgresql@15-main.service - PostgreSQL Cluster 15-main.

which points to cluster 15 not cluster 16. I still don’t know how to fix though ^^’

That’s quite complicated…
Did you finally succeed to reinstall immich without errors ? Is it a new install from scratch or you restore an older backup ?
Immich is using postegresql 16 so you should see a running systemd service named postgresql@16-main.service

I did a new install from scratch. Don’t really know what changed but waiting and rebooting more. The backup really did not want to restore itself.
I don’t know how to check properly for postgresql version. I tried

  • systemctl list-unit-files | grep postgre which gave no information on version
    postgresql.service                                                enabled         enabled
    postgresql@.service                                               indirect        enabled
    
  • psql --version gave psql (PostgreSQL) 17.5 (Debian 17.5-1.pgdg120+1)
  • looked in yunohost gui for services and I see one postgresql service and no direct mention of version, only the 15 that is mentioned in the logs

I know that I selected 16 for the commands I did and I still can see immich db with password from env so I don’t know what it is trying to do wrong.
I also don’t know what more information I could give but if you think about anything that could be useful I’ll do gladly

Whats the output of:

  • systemctl list-units | grep postgre
  • yunohost app info immich
  postgresql.service                                                                               loaded active exited    PostgreSQL RDBMS
  postgresql@15-main.service                                                                       loaded active running   PostgreSQL Cluster 15-main
  postgresql@16-main.service                                                                       loaded active running   PostgreSQL Cluster 16-main
  postgresql@17-main.service                                                                       loaded active running   PostgreSQL Cluster 17-main
  system-postgresql.slice                                                                          loaded active active    Slice /system/postgresql

et

description: Photo and video backup solution directly from your mobile phone
domain_path: immich.n0isette.ynh.fr/
name: Immich
version: 1.132.3~ynh1

Without any restore is the app working ?
Are all the 3 services active & running:

  • postgresql@16-main.service
  • immich-server.service
  • immich-machine-learning.service

The app seemed to be working before any restore. I didn’t push through initial config though.
As you saw postgresql@16-main.service is active and running.
I checked: immich-machine-learning.service is active too.
Right now immich-server.service is not now but I think it is because it crashed since I launched it back from yunohost UI before trying and it is the logs of this service that mention authentication error.

Your command to restore the backup seems wrong.
I would try gunzip --stdout ../yunohost.app/immich/backups/immich-db-backup-1746921600012.sql.gz | sed "s/SELECT pg_catalog.set_config('search_path', '', false);/SELECT pg_catalog.set_config('search_path', 'public, pg_catalog', true);/g" | sudo --login --user=postgres PGUSER=postgres PGPASSWORD="$(cat /etc/yunohost/psql)" psql --cluster="16/main" --dbname="immich"

1 Like

You could also try to fist redifnie the immich db password with that command:
sudo --login --user=postgres PGUSER=postgres PGPASSWORD="$(cat /etc/yunohost/psql)" psql --cluster="16/main" immich --command="ALTER ROLE immich PASSWORD 'password';"

The password within single quotes is the one obtain with that command cat /etc/yunohost/apps/immich/settings.yml | yq -r .psql_pwd

1 Like

I did both manipulations and it worked beautifully!
I crafted the command guessing rather than understanding so I am not surprised that it was wrong. I am really happy to have my pictures and albums and all back online :blush:
Thanks a lot for your help!

1 Like