PostgreSQL: pg_upgrade 9.5 to 13 failing with "connection to database failed: FATAL: database "template1" does not exist"
From the PostgreSQL mailing list:
The problem is that postgis, through gdal, ends up being linked to two different versions of proj at the same time.
You can check it by doing:
ldd /usr/pgsql-13/lib/postgis_raster-3.so | grep proj
If that shows up two different proj libraries, then you have that same problem.
In this case, uninstall the OS supplied proj library. If that removes postgis through dependency, let it and then install it with:
dnf install --excludepkg proj --excludepkg proj-datumgrid postgis30_13