Password Authentication Fails with Postgres

Hello,
I’m using Nextcloud 16.0.0.1 on Armbian (customized Ubuntu 18.04), with Postgresql 10.1 and Nginx.

When I try to run the installation program (using the command line), I get an error:

Error while trying to create admin user: Failed to connect to the database: An exception occurred in driver: SQLSTATE[08006] [7] FATAL:  password authentication failed for user "nextcloud"
FATAL:  password authentication failed for user "nextcloud"

I made sure in pg_hba.conf that md5 is an allowed auth method on localhost. I’ve confirmed with sudo -u www-data psql -U nextcloud nextcloud that I’m able to log in to the database using the password that I’ve given to the occ command.

The exact command I used is:

sudo -u www-data php occ maintenance:install --database "pgsql" --database-name "nextcloud" --database-user "nextcloud" --database-pass "{database pass}" --admin-user "miakramer" --admin-pass "{admin pass}" --data-dir "/data/www/nextcloud/data" --database-host "localhost:5432"

Any thoughts on what I might be doing wrong?

Is postgres listening on 127.0.0.1? AFAIK one has to enable this explicitly in postgresql.conf.

did you try without port number in --database-host?
did you try peer auth?

I was using the docker-compose installation instructions here and I got the same error when I attempted to log into the Nextcloud portal… which is how I got to this post.

I found that the docker-compose orchestration failed to setup postgres with a database and user correctly. After I created the database manually, as well as created the user with the expected password, everything worked.

Honestly, you validated that you could login with psql -U nextcloud nextcloud - which failed for me. So I don’t think my experience with this error will be helpful for you… sorry.