Install confluence and connect to running PostgreSQL DB
Asked by Hans-Georg Emberger:

I have installed confluence, postgreSQL and the database for confluence.  
When I try to connect, test is not successful  

**Can't reach database server or port**

SQLState - 08001  
org.postgresql.util.PSQLException: Connection to mail.nochricht.de:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.

On the server I have opened the ufw firewall to allow 8090 and tcp/5432

Whsat else could be the missing piece?


Answers:
author: Nic Brough -Adaptavist-
body: Postgres has a pg_hba.conf file which controls security and I **always** get wrong.

That has to be configured to allow connections from your Confluence server, and with the right type of password.

For example, this one is one I have at home, configured for "any machine on my local network" by the last line. Before I added that, my Confluence got the same message as you.

nic@stannis:\~$ sudo cat /etc/postgresql/9.4/main/pg_hba.conf  
\[sudo\] password for nic:  
# PostgreSQL Client Authentication Configuration File  
# ===================================================

lots of "how to use this file" words I removed

# ===================================================  
# DO NOT DISABLE!  
# If you change this first entry you will need to make sure that the  
# database superuser can access the database using some other method.  
# Noninteractive access to all databases is required during automatic  
# maintenance (custom daily cronjobs, replication, and similar tasks).  
#  
# Database administrative login by Unix domain socket  
local all postgres md5  

# TYPE DATABASE USER ADDRESS METHOD  

# "local" is for Unix domain socket connections only  
local all all peer  

# IPv4 local connections:  
host all all 127.0.0.1/32 md5  
# IPv6 local connections:  
host all all ::1/128 md5  
# Allow replication connections from localhost, by a user with the  
# replication privilege.  
#local replication postgres peer  
#host replication postgres 127.0.0.1/32 md5  
#host replication postgres ::1/128 md5  
host all all 192.168.1.0/24 md5

comments: author: Hans-Georg Emberger
body: Hi Nic, thank you for the answer ... still did not find the settings which work ..  
What is the 24 behind the slash?


author: Nic Brough -Adaptavist-
body: It means "look at the first 24 bits of the address before the /" - translates to "192.168.1. (any number from 1 to 255)"

You did alter the IP range there to match your network? And restart postgres?

You can just put in the raw IP address of the server (Just 192.168.1.42 for example), which is more secure as it means "only that server".

But, if it's not the pg_hba.conf file refusing you access, it could be something else on your network.


author: Hans-Georg Emberger
body: Ok got it.

In my situation confluence runs on a vServer and I connect via the internet.  
So the access should be direct from confluence on this server to the db on this server  
host all all localhost md5  
but still not working ...


author: Hans-Georg Emberger
body: Expalining the traffic from localhost to localhost helped me to understand, that the db server is localhost and it worked.