Paperless doesn't start

What app is this about, and its version: paperless-ngx 2.17.1~ynh1
What YunoHost version are you running: 12.1.37 (stable)
What type of hardware are you using: Virtual machine

Describe your issue

I see this error messages on the app detail page:

Ein Fehler verhindert die Anzeige des Konfigurationsfensters:
Konnte die Werte des Konfigurations-Panels nicht auslesen.
Bitte leiten Sie diesen Fehler an das YunoHost-Team zu dessen Behebung weiter!

It’s from here:

Share relevant logs or error messages

Seems it comes from a broken update: https://paste.yunohost.org/raw/unedulicif

The app can be upgraded from version 2.17.1~ynh1 to 2.20.3~ynh1

paperless app is not listed on: `/yunohost/admin/#/services`

See also: upgraded from version 2.17.1~ynh1 to 2.20.3~ynh1 is broken · Issue #219 · YunoHost-Apps/paperless-ngx_ynh · GitHub

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.

I try to fix it now, again…

First error was:

Warning: File or folder '/var/www/paperless-ngx' to be backed up does not exist
Error: Failed to collect files to backed up for paperless-ngx.

So i just mkdir it and tried again…

Then it ends with:

Warning: /var/cache/yunohost/app_tmp_work_dirs/app_0qm7yfeh/scripts/backup: line 19: data_dir: unbound variable
Error: Failed to collect files to backed up for paperless-ngx.

Seems i have a good last backup without any loss data:

root@YunoHost:~# find /home/yunohost.app/paperless-ngx/ -type f -printf '%TY-%Tm-%Td %TH:%TM %p\n' | sort -nr | head -n 5
2025-12-22 16:04 /home/yunohost.app/paperless-ngx/data/log/paperless.log
2025-12-22 16:04 /home/yunohost.app/paperless-ngx/data/log/celery.log
2025-12-22 16:04 /home/yunohost.app/paperless-ngx/data/celerybeat-schedule.db.db
2025-12-22 16:00 /home/yunohost.app/paperless-ngx/data/log/mail.log
2025-12-22 15:57 /home/yunohost.app/paperless-ngx/media/media.lock

root@YunoHost:~# find /home/yunohost.backup/archives/ -type f -printf '%TY-%Tm-%Td %TH:%TM %p\n' | grep paperless | sort -nr | head -n 5
2025-12-22 16:04 /home/yunohost.backup/archives/paperless-ngx-pre-upgrade1.tar.gz
2025-12-22 16:04 /home/yunohost.backup/archives/paperless-ngx-pre-upgrade1.info.json

So last changed file is from 2025-12-22 16:04 as the last backup of v2.17.1~ynh1.

So i try to deinstall the app and restore 2.17.1~ynh1 from the backup. Hope that fixed the issues.

EDIT: This works: Now i have a running 2.17.1~ynh1 back … No i will create a normal backup and try to upgrade…

EDIT2: upgraded from version 2.17.1~ynh1 to 2.20.3~ynh1 doesn’t work, because PostgreSQL 14 is needed, see:

...
Warning:   File "/var/www/paperless-ngx/venv/lib/python3.11/site-packages/django/db/backends/postgresql/base.py", line 398, in init_connection_state
Warning:     super().init_connection_state()
Warning:   File "/var/www/paperless-ngx/venv/lib/python3.11/site-packages/django/db/backends/base/base.py", line 225, in init_connection_state
Warning:     self.check_database_version_supported()
Warning:   File "/var/www/paperless-ngx/venv/lib/python3.11/site-packages/django/db/backends/base/base.py", line 201, in check_database_version_supported
Warning:     raise NotSupportedError(
Warning: django.db.utils.NotSupportedError: PostgreSQL 14 or later is required (found 13.20).
Error: Failed to upgrade paperless-ngx: An error occurred inside the app upgrade script

So i assume 2.20.3~ynh1 doesn’t work with

EDIT3: Hm! In YunoHost v12.1 with bookworm Postgres v15 and v16 should be available… And it’s installed:

root@YunoHost:~# apt list --installed 'postgresql-*'
Listing... Done
postgresql-13/now 13.20-0+deb11u1 amd64 [installed,local]
postgresql-15/oldstable,now 15.14-0+deb12u1 amd64 [installed]
postgresql-16-pgvector/now 0.8.1-2.pgdg12+1 amd64 [installed,local]
postgresql-16/now 16.11-1.pgdg12+1 amd64 [installed,local]
postgresql-client-13/now 13.20-0+deb11u1 amd64 [installed,local]
postgresql-client-15/oldstable,now 15.14-0+deb12u1 amd64 [installed,automatic]
postgresql-client-16/now 16.11-1.pgdg12+1 amd64 [installed,local]
postgresql-client-common/now 264.pgdg110+1 all [installed,local]
postgresql-common/now 264.pgdg110+1 all [installed,local]
postgresql-contrib/oldstable,now 15+248+deb12u1 all [installed,automatic]

root@YunoHost:~# pg_config --version
PostgreSQL 16.11 (Debian 16.11-1.pgdg12+1)

root@YunoHost:~# psql --version
psql (PostgreSQL) 16.11 (Debian 16.11-1.pgdg12+1)

So what’s the problem here?!?

1 Like

Hello @jedie
From your last log, this does seem to be the same problem I had in my issue that you linked to.
The way I solved this is by running as root the following commands:

cd /var/www/paperless-ngx
source venv/bin/activate
pip uninstall psycopg-c
pip install -r requirements.txt

I hope this helps!

Best,
–waz

1 Like

I had the same kind of problem.
I used your solution.
It works perfectly.

Thanks :grinning_face:

I would highly recommend doing so in PaperLess-NGX app shell to avoid permission issues:

sudo yunohost app shell paperless-ngx

The rest of the commands remain unchanged.

Thanks, I did not know this existed! Do you know if this shell runs directly in paperless’s venv?
Btw, I think there is a typo in your command (-nxg +ngx)

EDIT: just checked, it does. So the fix is now:

sudo yunohost app shell paperless-ngx
pip uninstall psycopg-c
pip install -r requirements.txt
1 Like

I didn’t get it working.

The problem is: Updating 2.17.1~ynh1 to 2.20.6~ynh1 will start, failed and the old version will be recovered from last backup.

So i see no point when i can call pip uninstall psycopg-c

Can somebody list all steps to get this woking?

Maybe upgrade: pip uninstall psycopg-c by jedie · Pull Request #233 · YunoHost-Apps/paperless-ngx_ynh · GitHub is a fix for all?

1 Like
  1. MAKE FULL APP BACKUP
  2. Manually upgrade disabling safety backup. It’ll leave the app in broken state as there’s no backup to revert to.
sudo yunohost app upgrade paperless-ngx -u https://github.com/YunoHost-Apps/paperless-ngx_ynh/tree/master --no-safety-backup
  1. Apply fixes as suggested by @wazdra
1 Like

The auto fix solution upgrade: pip uninstall psycopg-c by jedie · Pull Request #233 · YunoHost-Apps/paperless-ngx_ynh · GitHub doesn’t do the job :frowning:

I will try the manually fix…

EDIT1: The manually fix is:

sudo yunohost app shell paperless-ngx
pip uninstall psycopg-c
pip install -r /var/www/paperless-ngx/requirements.txt

Because the cwd is /var/www/paperless-ngx/src and the requirements.txt is in: /var/www/paperless-ngx/requirements.txt e.g.:

sudo yunohost app shell paperless-ngx
paperless-ngx@YunoHost:~/src$ pwd
/var/www/paperless-ngx/src

Do you have any pending migration under ‘WebAdmin->Tools->Migrations’? I’m asking because it’s unusual to run PostgreSQL 13 on Debian Bookworm (15 is the default).

no:

But i still have old versions installed:

root@YunoHost:~# apt list --installed 'postgresql-*'
Listing... Done
postgresql-13/now 13.20-0+deb11u1 amd64 [installed,local]
postgresql-15/oldstable-security,now 15.16-0+deb12u1 amd64 [installed]
postgresql-16-pgvector/now 0.8.2-1.pgdg12+1 amd64 [installed,local]
postgresql-16/now 16.13-1.pgdg12+1 amd64 [installed,local]
postgresql-client-13/now 13.20-0+deb11u1 amd64 [installed,local]
postgresql-client-15/oldstable-security,now 15.16-0+deb12u1 amd64 [installed,automatic]
postgresql-client-16/now 16.13-1.pgdg12+1 amd64 [installed,local]
postgresql-client-common/now 264.pgdg110+1 all [installed,local]
postgresql-common/now 264.pgdg110+1 all [installed,local]
postgresql-contrib/oldstable,now 15+248+deb12u1 all [installed,automatic]

The migration 29. Migrate databases from PostgreSQL 13 to 15 was not really successful?!?

Maybe i must do something like 2 postgres instance - #2 by djez (But it’s in french and i didn’t understand french)

I assume i have a mixed postgres:

I need some help to fix this.

the differen postgres version problem is discussed here: Discuss about postgresql migration on debian major upgrade · Issue #2737 · YunoHost/issues · GitHub and it’s the same as [Synapse] Instant messaging server matrix network - #159 by aven

Hi @jedie,

This is exactly the same issue I described in the other topic. Your PostgreSQL migration from 13 to 15 didn’t complete properly → the old cluster (v13) is still listening on port 5432 (the default), so all your apps connect to it instead of the newer v15 cluster. That’s why Django complains about “PostgreSQL 14 or later is required (found 13.20)”.

Here’s how to fix it. All commands assume you’re working as root.


Step 0 → Get a clear picture of your clusters:

pg_lsclusters

This will show you all running clusters with their version, port, and status. You likely have something like:

  • v13 on port 5432 (the problematic one → apps connect here by default)
  • v15 on port 5433 (the one that should be used)
  • v16 on port 5434 (likely used by Immich, with pgvector → don’t touch this one)

Note down the exact ports before proceeding.


Step 1 → Check which databases exist on each cluster:

# Databases on the v13 cluster (likely port 5432)
sudo -u postgres psql -p 5432 -l

# Databases on the v15 cluster (likely port 5433)
sudo -u postgres psql -p 5433 -l

→ Compare both lists. If all your app databases (paperless-ngx, and any other) are already present on the v15 cluster, skip to Step 2. If some databases only exist on v13 and are missing from v15, you need to migrate them manually first → see Step 1.1 below.

Step 1.1 → Manually migrate a database from v13 to v15 (only if needed):

For each database that exists on v13 but is missing from v15, follow this procedure. Replace <dbname> and <dbuser> with the actual values.

First, identify the database owner on v13:

sudo -u postgres psql -p 5432 -c "\l" | grep <dbname>

Find the app’s database password in its YunoHost settings:

cat /etc/yunohost/apps/<appname>/settings.yml | grep db_pwd

Dump the database from the v13 cluster:

sudo -u postgres pg_dump -p 5432 <dbname> > /tmp/<dbname>.sql

Make sure the role (user) exists on the v15 cluster:

sudo -u postgres psql -p 5433 -c "\du" | grep <dbuser>

If the role doesn’t exist, create it (use the password from the settings above):

sudo -u postgres psql -p 5433 -c "CREATE ROLE <dbuser> WITH LOGIN PASSWORD '<the_password>';"

Create the database on v15 and restore the dump:

sudo -u postgres psql -p 5433 -c "CREATE DATABASE <dbname> OWNER <dbuser>;"
sudo -u postgres psql -p 5433 <dbname> < /tmp/<dbname>.sql

Verify the data is there:

sudo -u postgres psql -p 5433 -c "\dt" <dbname>

Clean up:

rm /tmp/<dbname>.sql

Repeat for each missing database, then proceed to Step 2.


Step 2 → Check which apps use PostgreSQL:

grep -r "db_type\|psql\|postgres" /etc/yunohost/apps/*/settings.yml

This helps you know which apps will be affected by the port change.


Step 3 → Stop the old v13 cluster (safe first step → don’t delete it yet):

pg_ctlcluster 13 main stop

Step 4 → Reconfigure the v15 cluster to use port 5432:

systemctl stop postgresql@15-main
nano /etc/postgresql/15/main/postgresql.conf
# Change: port = 5433 → port = 5432
systemctl start postgresql@15-main

Step 5 → Verify:

pg_lsclusters

You should see:

  • v15 on port 5432, status online
  • v13 stopped/down
  • v16 unchanged on its own port (if applicable)

At this point, you can test that your existing apps still work properly.


Step 6 → Once everything works, remove the old v13 cluster and packages:

pg_dropcluster 13 main
apt remove postgresql-13 postgresql-client-13

Step 7 → Upgrade paperless-ngx:

Since normal upgrades fail and roll back automatically, use the approach suggested by @orhtej2:

  1. First, make a full backup:

    yunohost backup create --apps paperless-ngx
    
  2. Then upgrade without safety backup (so it won’t roll back on failure):

    yunohost app upgrade paperless-ngx --no-safety-backup
    
  3. If the psycopg-c issue still occurs after upgrade, apply the fix:

    yunohost app shell paperless-ngx
    pip uninstall psycopg-c
    pip install -r /var/www/paperless-ngx/requirements.txt
    

Important note about PostgreSQL 16: You have postgresql-16-pgvector installed, which is very likely used by Immich (or a similar app). This cluster should be running on its own port (probably 5434) and should not be affected by the changes above. Just make sure you don’t touch it during this process. You can verify with pg_lsclusters which port v16 uses.

Good luck! :slightly_smiling_face:

1 Like

Thanks! That helps a lot.

In my case it was Postgres 13 and 16:

pg_lsclustersVer Cluster Port Status Owner    Data directory              Log file13  main    5432 online postgres /var/lib/postgresql/13/main /var/log/postgresql/postgresql-13-main.log16  main    5433 online postgres /var/lib/postgresql/16/main /var/log/postgresql/postgresql-16-main.log

Sad that the migration doesn’t do the job, i tried:

yunohost tools migrations run postgresql_13_to_15 --force-rerun

But it just ran into an error. Think it’s not so robust to handle my mixed case.

I doesn’t used your idea with manually SQL dump/restore. What i have done was:

  1. Backup of all Apps that still used postgres 13
  2. Deinstall these apps
  3. Stop the v13 cluster
  4. changed the port of v16
  5. deinstalled v13
  6. restore the Apps

After this, all apps used v16 and i can apply the missing app updates.

EDIT: One missing part seems to change the postgres version in /etc/postgresql-common/user_clusters

Last App that restore results in Problem is immich

Now i try to install it first and then apply the immich update. But now i see that the immich installation installs postgres v17 → immich_ynh/manifest.toml at ccefab6fdb7d465d47437f544de8aee0552aa218 · Majentas/immich_ynh · GitHub