Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections

I was getting this error while trying to connect my openfire server with postgresql database. Well let

me show you the step to fix this error.

Error:

Connection refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections

Solution:

This can happen due to following 2 reason

  • Your Firewall is blocking postgresql from making connection.
  • You have not configured your postgresql database on the server to accept connection from particular machines on the network
For firewall rules
# iptables -A INPUT -s 0.0.0.0/0 -p tcp --dport 5432 -j ACCEPT
# iptables -A INPUT -s 0.0.0.0/0 -p udp --dport 5432 -j ACCEPT

For postgresql configuration
# vi /var/lib/pgsql/data/postgresql.conf
Look out for this line
listen_addresses = 'localhost'

and change it to
listen_addresses = '*'

Restart the database services
# service postgresql restart
Stopping postgresql service:                              
[  OK  ]
Starting postgresql service:                               [  OK  ]
Now try connecting to the postgresql database using openfire. Let me know your success and failure