Connection refused error when connecting to PostgreSQL

3

The error happens after entering login and password:

  

"Deuorg.postgresql.util.PSQLException: Connection refused. Check that   the hostname and port are correct and that the postmaster is accepting   TCP / IP connections. "

I'm making the connection this way and I need it to stay that way for now:

<%
String url = "jdbc:postgresql://postgres-postgresconection.jelastic/siscosi";
String usuario = "xxxx";
String senha = "xxxx";
try {
    Class.forName("org.postgresql.Driver");
    Connection conexao = DriverManager.getConnection(url, usuario, senha);
    
asked by anonymous 06.06.2014 / 14:13

2 answers

1

By default, when you create a Jelastic environment with a database, such a database can only be accessed by applications in the same environment or by the web page (such as phpPgAdmin ).

So, to access the database you need to enable the Public IPv4 Address option, and this will increase your monthly cost a little more. By doing so, you will receive IP to access it remotely and then add the IP as hostname in the connection URL.

In short, you must have a valid IP to remotely access your database and your connection URL will look like this:

"jdbc:postgresql://IPRecebido/siscosi"

More information you can find here: Jelastic - PostgreSQL Remote Access

    
05.09.2014 / 14:14
0

The Postgres connection url should follow the following template

jdbc:postgresql://host:port/database

If the port is not specified, it will use the postgres standard that is 5432

Apparently the name entered for the host is invalid

  

postgres-postgresconection.jelastic

Maybe .com is missing from the postgres-postgresconection.jelastic.com address and the port, if different from 5432

    
06.06.2014 / 14:24