I cannot connect Confluence to a postgresql db
Asked by Joss Ellis:

I hope someone can help here...

I have a new Dell server running Debian 8.1

I have JIRA successfully running on this server connected to a postgresql db ('jiradb' with user 'jira')

I've installed a 10 user Confluence test on the same server and that seems to have installed fine and I can get it up on a browser via the standard 8090 port.

I created the database 'confdb' with user 'confuser'

However when I fill in the details on the webpage I get 2 errors

The following error(s) occurred:

* configuring.db.failed
* org.postgresql.util.PSQLException: FATAL: password authentication failed for user "confuser"

here's the JIRA database config in case that helps...

cat atlassian/application-data/jira/dbconfig.xml  
\<?xml version="1.0" encoding="UTF-8"?\>

\<jira-database-config\>  
\<name\>defaultDS\</name\>  
\<delegator-name\>default\</delegator-name\>  
\<database-type\>postgres72\</database-type\>  
\<schema-name\>public\</schema-name\>  
\<jdbc-datasource\>  
\<url\>jdbc:postgresql://127.0.0.1:5432/jiradb\</url\>  
\<driver-class\>org.postgresql.Driver\</driver-class\>  
\<username\>jira\</username\>  
\<password\>\*\*\*\*\</password\>  
\<pool-min-size\>20\</pool-min-size\>  
\<pool-max-size\>20\</pool-max-size\>  
\<pool-max-wait\>30000\</pool-max-wait\>  
\<pool-max-idle\>20\</pool-max-idle\>  
\<pool-remove-abandoned\>true\</pool-remove-abandoned\>  
\<pool-remove-abandoned-timeout\>300\</pool-remove-abandoned-timeout\>  
\</jdbc-datasource\>  
\</jira-database-config\>

I'm trying to use the following for confluence

Driver Class Name ... org.postgresql.Driver

Database URL jdbc:[postgresql://localhost:5432/conf](postgresql://localhost:5432/confluence)db

User Name confuser

Pawssword xxxxx

Thanks in advance  
Joss  


Answers:
author: Joss Ellis
body: Answering my own question here, but thought I would in-case anyone else gets this.

<br />

I deleted the database mentioned above  
created a database user called confluence  
created a database called confdb owned by confluence.  
re-ran the web app and bingo it worked.

So it did appear for me in Linux that I needed a database user with the same name as the user who runs and owns all the confluence processes (i.e. the default 'confluence' user that's set up on install.)

comments: author: Michael Gruben-Trejo
body: I'm installing PostgreSQL and Confluence in Windows.

These steps are exactly what I needed to get Confluence to connect to the newly-installed PostgreSQL server.

To create the database and user, you can use pgAdmin4, if you'd prefer a GUI interface.


author: Luiz Maia
body: Hi Joss,

I strongly believe your "confuser" has not been set as database owner for the "confdb" schema.

Can you confirm if the login role for the database is correct?

Thanks!

Regards,  
Luiz Maia

comments: author: Joss Ellis
body: Hi Luiz,Thanks for the reply ... that doesn't seem to be the issue sadly.logging in as the user 'postgres' and running psql gives:-postgres=# \\du List of roles Role name \| Attributes \| Member of-----------+------------------------------------------------+----------- confuser \| Create role, Create DB \| {} jira \| Create DB \| {} postgres \| Superuser, Create role, Create DB, Replication \| {}and postgres=# \\l List of databases Name \| Owner \| Encoding \| Collate \| Ctype \| Access privileges-----------+----------+----------+-------------+-------------+----------------------- confdb \| confuser \| UTF8 \| en_AU.UTF-8 \| en_AU.UTF-8 \| jiradb \| jira \| UTF8 \| en_AU.UTF-8 \| en_AU.UTF-8 \| postgres \| postgres \| UTF8 \| en_AU.UTF-8 \| en_AU.UTF-8 \| template0 \| postgres \| UTF8 \| en_AU.UTF-8 \| en_AU.UTF-8 \| =c/postgres + \| \| \| \| \| postgres=CTc/postgres template1 \| postgres \| UTF8 \| en_AU.UTF-8 \| en_AU.UTF-8 \| =c/postgres + \| \| \| \| \| postgres=CTc/postgres(5 rows)I do wonder if the problem might be having 'confuser' rather than the user 'confluence' which also owns the install of confluence.i.e. I have these Linux usersjirapostgresconfuserconfluenceCHeersJoss


author: Nic Brough -Adaptavist-
body: There's not a lot we can tell you I'm afraid - the database is rejecting the username/password combination and the system is telling you that that is the response from the database.

There's lots of reasons jdbc will fail to connect to a postgres database, but it reports "username/password" for a lot of them.

The first question is can you use psql -H localhost -U confuser -W (xxxxxxx) to get into the database on the command line? That will probably also fail, but it should give you the actual error instead of just username/password (if it still says username password, then your xxxxxx is wrong, use the system account to reset it)

comments: author: Joss Ellis
body: Thanks for the feedback Nic,so I tried thisroot@Perforce1:/home# su - postgrespostgres@Perforce1:\~$ psqlpostgres=# ALTER USER confuser WITH PASSWORD 'confuser';ALTER ROLEpostgres=# \\qpostgres@Perforce1:\~$ psql -H localhost -U confuser -w confuserpsql: warning: extra command-line argument "confuser" ignoredpsql: FATAL: Peer authentication failed for user "confuser"postgres@Perforce1:\~$ psql -H localhost -U confuser -wpsql: FATAL: Peer authentication failed for user "confuser"postgres@Perforce1:\~$ su - confuserPassword:\<I typed confuser\>confuser@Perforce1:\~$Shouldn't this have forced the password ?ThanksJoss


Tags: confluence-administration