"Connection refused" error when connecting to Postgresql

Asked

Viewed 3,658 times

3

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 that 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);
  • The postgres server is on a different machine than yours?

  • 1

    As the error already says: Yours hostname and/or porta is wrong, see if everything is typed correctly or if the information is true in relation to the address of your server.

  • 1

    fix I put this url first : String url = "jdbc:postgresql://localhost:5432/database name"; , and my postgres look like this: Postgresql 8.4.18 running on localhost:5432 -- You are logged in as a "webadmin" user. now do not know if the postgres of Jestastic

  • 1

    Enter your cloud control panel and take your server settings and [Edit] and the question, then it’s easier to tell what the connection string will be for you

  • personnel informed me that is error in connection socket the service of postgre must be off. But how do I turn on this service?

  • Go to Windows services and see if it’s running. Open run, type in services.Msc and enter. Search for postgresql and see if it’s running.

  • @Roque, where are you running your Web application server? I also use the Jelastic platform, your problem should be the same as I’ve had before.

Show 2 more comments

2 answers

1

By default when creating an environment in the Jelastic with a database, such a database can only be accessed by applications in the same environment or by the website (such as the phpPgAdmin).

Then, to access the database it is necessary to enable the option Public address Ipv4, and this will increase a little more your monthly cost. By doing so, you will receive a 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

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 that is 5432

Apparently the given hostname is invalid

postgres-postgresconection.jelastic

Perhaps the .with of the address postgres-postgresconection.jelastic.com and the door, if different from 5432

  • put so now and nothing: String url = "jdbc:postgresql://postgres-postgresconection.jelastic.com:5432/database name"

Browser other questions tagged

You are not signed in. Login or sign up in order to post.