Unable to connect to Postgresql

After upgrading from Fedora 33 to 34 Nextcloud is unable to connect to the database. The database was upgraded successfully from Postgresql 12 to 13.

I can successfully access the nextcloud database using psql with the postgresql nextcloud user and password.

I’m guessing that the problem might be with pg_hba.conf or .htaccess but so far I’m unable to fix the problem. Any troubleshooting hints would be appreciate.

Details
Nextcloud version: 21.0.3
Operating system and version: Fedora 34
Apache 2.4.48
PHP version 7.4.21

The output of php-fpm www-error.log

[20-Jul-2021 16:40:47 America/Los_Angeles] PHP Fatal error:  Uncaught Doctrine\DBAL\Exception: Failed to connect to the database: An exception occurred in the driver: SQLSTATE[08006] [7] FATAL:  Ident authentication failed for user "nextclouduser" in /opt/nextcloud/lib/private/DB/Connection.php:85
Stack trace:
#0 /opt/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(1486): OC\DB\Connection->connect()
#1 /opt/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(1014): Doctrine\DBAL\Connection->getWrappedConnection()
#2 /opt/nextcloud/lib/private/DB/Connection.php(226): Doctrine\DBAL\Connection->executeQuery()
#3 /opt/nextcloud/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php(210): OC\DB\Connection->executeQuery()
#4 /opt/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php(287): Doctrine\DBAL\Query\QueryBuilder->execute()
#5 /opt/nextcloud/lib/private/AppConfig.php(345): OC\DB\QueryBuilder\QueryBuilder->execute()
#6 /opt/nextcloud/lib/private/AppConfig.php(110): OC\AppConfig->loadConfigValues()
#7 /opt/nextcloud/lib/private/AppConfig.php(301): OC\AppConfig->getApp in /opt/nextcloud/lib/private/DB/Connection.php on line 85