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