Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

postgres Connection: Error - Connection refused

avatar
Contributor

I'm trying to install a cluster using Ambari.

I've made it all the way to step 7: Customize Services. At this point, the wizard is asking me to test the db connection to the embedded postgresql db. As you might have guessed, it's failing with the following message:

2018-05-17 04:09:26,200 - Check db_connection_check was unsuccessful. Exit code: 1. Message: May 17, 2018 4:09:26 AM org.postgresql.core.v3.ConnectionFactoryImpl log
WARNING: ConnectException occurred while connecting to slave1.c.my-project-1519895027175.internal:5432
java.net.ConnectException: Connection refused (Connection refused)
 at java.net.PlainSocketImpl.socketConnect(Native Method)
 at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
 at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
 at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
 at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
 at java.net.Socket.connect(Socket.java:589)
 at org.postgresql.core.PGStream.<init>(PGStream.java:69)
 at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:156)
 at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49)
 at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:195)
 at org.postgresql.Driver.makeConnection(Driver.java:452)
 at org.postgresql.Driver.connect(Driver.java:254)
 at java.sql.DriverManager.getConnection(DriverManager.java:664)
 at java.sql.DriverManager.getConnection(DriverManager.java:247)
 at org.apache.ambari.server.DBConnectionVerification.main(DBConnectionVerification.java:37)

May 17, 2018 4:09:26 AM org.postgresql.Driver connect
SEVERE: Connection error: 
org.postgresql.util.PSQLException: Connection to slave1.c.my-project-1519895027175.internal:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.



I've verified I can ping 'slave1' from the Ambari host machine and I've opened up port 5432 in the firewall. I'm really at a loss as to why the db won't connect.

For what it's worth, I'm installing on Google Cloud

The default params for the wizard are in the attachment

74463-screen-shot-2018-05-17-at-123748-am.png

2 REPLIES 2

avatar
Master Mentor

@Mike Wong

As you are selecting "Existing Postgresql Database", So you will need to make sure that you have done the presetup for Hive to use External Existing Postgres.

When you use "Existing" database options then you will need to make sure that the Database is already installed on the mentioned host and it is running fine (port 5432) is accessible and bound.

# netstat -tnlpa | grep 5432
# ps -ef | grep postgres

Please see the doc to know

how to use Oozie with an existing database, other than the Derby database instance that Ambari installs by default.

https://docs.hortonworks.com/HDPDocuments/Ambari-2.6.0.0/bk_ambari-administration/content/using_oozi...

avatar
Contributor

I figured it out, for that problem at least.

I had to edit the pg_hba.conf file to add the IP range of 'host' machine.