Postgresql authentication error

  • SonarQube server sonarqube-9.9.0.65466.
  • how is SonarQube deployed: zip on Ubuntu
  • Get server running

Original install:I unzipped in /opt andI used this link to set up the database: The rest is the same as your docs.

which does the following command to create a psql user
createuser sonar

psql 
ALTER USER sonar WITH ENCRYPTED password 'sonar';
CREATE DATABASE sonarqube OWNER sonar;
grant all privileges on DATABASE sonarqube to sonar;

In web .log I get this error messafe

Caused by: org.postgresql.util.PSQLException: FATAL: password authentication failed for user "sonar"

I changed the password with following command so that it is not encrypted

sudo -u sonar psql sonarqube
In sql command line 
>ALTER USER sonar WITH PASSWORD sonar;

I changed /etc/postgresql/14/main/pg_hba.conf

# "local" is for Unix domain socket connections only
local   all             all                                     password
# IPv4 local connections:
host    all             all             127.0.0.1/32            password
# IPv6 local connections:
host    all             all             ::1/128                 password

I get same error.
My sonar.properties has:

sonar.jdbc.url=jdbc:postgresql://localhost:5432/sonarqube
sonar.jdbc.username=sonar
sonar.jdbc.password=sonar
sonar.web.host="My eth0 ipaddress"
sonar.web.port=9000
sonar.web.context=/sonarqube

I have also tried putting trust in the last field of pg_hba.conf. I do not get the error but log file says there are no projects and I cannot connect.

Fixed issue.

1 Like