Nextcloud install script fails with postgresql database

SYSTEM INFORMATION
OS type and version Debian 12
Webmin version 2.101
Virtualmin version 7.7

Selecting a postgresql database when running the nextcloud install script results in this error.

Database connection failed : postgresql::execute_sql failed : DBI connect failed : connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL: Peer authentication failed for user "nc" failed!

The postgresql log shows the following three messages related to the error. ‘nc’ below is both the user and the database name.

nc@nc LOG: provided user name (nc) and authenticated user name (root) do not match
nc@nc FATAL: Peer authentication failed for user "nc"
nc@nc DETAIL: Connection matched pg_hba.conf line 95: "local all all peer"

A user name map must be added to pg_ident.conf. For example,

nc root nc

And an additional record added to pg_hba.conf for this particular connection. For example, matching the map above,

local all nc peer map=nc

This record should be above the record,

local all all peer

Once that’s in place the nextcloud install script completes successfully.