FATAL: data directory "/var/lib/postgresql/data" has wrong ownership
Hi Folks, I have been using immich for some time now. I recently tried updating from 1.131.1 to the latest version. The instructions mentioned that the postgres image has been updated so I downloaded the latest docker-compose and run the usual "docker compose pull && docker compose up -d" command to launch it.
I have not been able to use immich after this. Today I took backup of the immich data including library uploads and backups. I do not see anything in the postgres folder either. I was not able to restore immich_postgres logs because the container kept restarting.
The postgres container has these logs:
initdb: removing contents of data directory "/var/lib/postgresql/data" running bootstrap script ... The files belonging to this database system will be owned by user "postgres". This user must also own the server process. The database cluster will be initialized with locale "en_US.utf8". The default database encoding has accordingly been set to "UTF8". The default text search configuration will be set to "english". Data page checksums are enabled. fixing permissions on existing directory /var/lib/postgresql/data ... ok creating subdirectories ... ok selecting dynamic shared memory implementation ... posix selecting default max_connections ... 20 selecting default shared_buffers ... 400kB selecting default time zone ... Etc/UTC creating configuration files ... ok 2025-04-25 23:40:55.122 UTC [83] FATAL: data directory "/var/lib/postgresql/data" has wrong ownership 2025-04-25 23:40:55.122 UTC [83] HINT: The server must be started by the user that owns the data directory. child process exited with exit code 1This is my first post here. So would appreciate any guidance and let me know if I need to provide more data/logs to resolve this.
19 Replies
:wave: Hey @Terminator365,
Thanks for reaching out to us. Please carefully read this message and follow the recommended actions. This will help us be more effective in our support effort and leave more time for building Immich :immich:.
References
- Container Logs:
docker compose logs
docs
- Container Status: docker ps -a
docs
- Reverse Proxy: https://immich.app/docs/administration/reverse-proxy
- Code Formatting https://support.discord.com/hc/en-us/articles/210298617-Markdown-Text-101-Chat-Formatting-Bold-Italic-Underline#h_01GY0DAKGXDEHE263BCAYEGFJA
Checklist
I have...
1. :ballot_box_with_check: verified I'm on the latest release(note that mobile app releases may take some time).
2. :ballot_box_with_check: read applicable release notes.
3. :ballot_box_with_check: reviewed the FAQs for known issues.
4. :ballot_box_with_check: reviewed Github for known issues.
5. :ballot_box_with_check: tried accessing Immich via local ip (without a custom reverse proxy).
6. :ballot_box_with_check: uploaded the relevant information (see below).
7. :ballot_box_with_check: tried an incognito window, disabled extensions, cleared mobile app cache, logged out and back in, different browsers, etc. as applicable
(an item can be marked as "complete" by reacting with the appropriate number)
Information
In order to be able to effectively help you, we need you to provide clear information to show what the problem is. The exact details needed vary per case, but here is a list of things to consider:
- Your docker-compose.yml and .env files.
- Logs from all the containers and their status (see above).
- All the troubleshooting steps you've tried so far.
- Any recent changes you've made to Immich or your system.
- Details about your system (both software/OS and hardware).
- Details about your storage (filesystems, type of disks, output of commands like fdisk -l
and df -h
).
- The version of the Immich server, mobile app, and other relevant pieces.
- Any other information that you think might be relevant.
Please paste files and logs with proper code formatting, and especially avoid blurry screenshots.
Without the right information we can't work out what the problem is. Help us help you ;)
If this ticket can be closed you can use the /close
command, and re-open it later if needed.What folder / storage are you using for the DB_DATA_LOCATION
Also what OS are you on
Hi @Zeus , I am using DB_DATA_LOCATION=./postgres
and I am on ubuntu 24
Hm. What folder are you in with the docker files?
How did you install docker
I had docker installed by the instructions mentioned on the officeial website. I have Docker version 28.1.1, build 4eba377
No Snap?
I do not fully understand the first question, but I have a folder created for immich and just copied the docker compose and example.env file from the repo.
sudo apt list --installed | grep docker
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
docker-buildx-plugin/now 0.23.0-1~ubuntu.20.04~focal amd64 [installed,local]
docker-ce-cli/now 5:28.1.1-1~ubuntu.20.04~focal amd64 [installed,local]
docker-ce-rootless-extras/now 5:28.1.1-1~ubuntu.20.04~focal amd64 [installed,local]
docker-ce/now 5:28.1.1-1~ubuntu.20.04~focal amd64 [installed,local]
docker-compose-plugin/now 2.35.1-1~ubuntu.20.04~focal amd64 [installed,local]
I installed docker via apt.
never had any trouble with docker containers prior to this upgrade.
what is the full working folder path for the immich folder with the compose
and what is the backing filesystem/mount for this path
I have an NTFS drive mounted to (/mnt/space) and here is the full path link: /mnt/space/immich-app
you cannot use NTFS for the database
I am honestly surprised it ever worked before today
yeah, I have all read/write permissions, I had planned to move it to FAT system in linux. I had extended linux partition specifically for that. But yes, I did not run into any issues.
Please don’t use FAT
Use ext4
okay, yeah I'll use that.
do you have any insight into what might be the root cause for this issue?
Yes it’s the use of NTFS
It doesn’t support user/group
okay, so If I move to ext4, then it should work then, right? Do I just move the database to ext4 or the upload files too?
oh wait, I just realized something. give me a few minutes to try it.
I think I followed these instructions last time to make it work on ntfs: https://immich.app/docs/install/requirements#special-requirements-for-windows-users. I found pgdata volume in my docker compose backup file.
However, it is not working now.
Update: if I use docker volume instead of bind mount, it works. the postgres server started and I have restored the db backup. But I am facing a password authentication failed in immich_server.
[Nest] 20 - 04/25/2025, 5:16:46 PM LOG [Microservices:EventRepository] Initialized websocket server microservices worker error: PostgresError: password authentication failed for user "postgres", stack: PostgresError: password authentication failed for user "postgres" at ErrorResponse (/usr/src/app/node_modules/postgres/cjs/src/connection.js:790:26) at handle (/usr/src/app/node_modules/postgres/cjs/src/connection.js:476:6) at Socket.data (/usr/src/app/node_modules/postgres/cjs/src/connection.js:315:9) at Socket.emit (node:events:518: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 1I although still need to lookup at how to reset the password for the user postgres in the db. Update: I reset the password and restarted the containers, but immich instance was empty. once it tried to restore data, then I get the above error again.
It sounds like you didn’t restore properly
Yeah, final update:
Solved it. I had to specify a new db location (in ext 4). Then restored the db as specified on the website. Since I did not remember the old db password (which the backup was generated from), I had to manually enter the container and reset the password. After doing this, I just had to restart the postgres db container and it works now. Thank you @Zeus .
Excellent! Nice job
Welcome back 🙂
thank you, bro!