1

I am trying to connect to Postgres and this is the error message that I get:

[main] INFO org.hibernate.connection.DriverManagerConnectionProvider - using driver: org.postgresql.Driver at URL: jdbc:postgresql://localhost:5433/postgres
[main] INFO org.hibernate.connection.DriverManagerConnectionProvider - connection properties: {user=postgres, password=****}
[main] WARN org.hibernate.cfg.SettingsFactory - Could not obtain connection to query metadata
org.postgresql.util.PSQLException: Connection refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.

I have verified that username/password is fine in my hibernate.conf

    <!-- Database connection settings -->
    <property name="connection.driver_class">org.postgresql.Driver</property>
    <property name="connection.url">jdbc:postgresql://localhost/postgres</property>
    <property name="connection.username">postgres</property>
    <property name="connection.password">*******</property>

This is my pg_hba.conf

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
# IPv6 local connections:
host    all             all             ::1/128                 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
# host   postgres,replication    localhost   127.0.0.1/32    md5
# host   postgres,replication    localhost   ::1/128     md5
host     all     all     0.0.0.0/0   md5

I am working on Windows (Not UNIX). So please suggest how I can fix this issue.

Thanks!

3
  • hi Postgres by default runs on port 5432 . Check whether your postgres process is running or not and if yes then on which port. Commented Oct 18, 2013 at 7:31
  • The postgres is running on 5432. I did check that but still the same issue. Please check my pg_hba.conf if i need to make any changes yet. Commented Oct 18, 2013 at 7:33
  • NFO org.hibernate.connection.DriverManagerConnectionProvider - using driver: org.postgresql.Driver at URL: jdbc:postgresql://localhost:5433/postgres..As per your log you are trying to make a connection on 5433 and your postgres is running on 5432 Commented Oct 18, 2013 at 7:40

1 Answer 1

2

where is port no in the connection url . jdbc:postgresql://localhost:portno/postgres

so final url should be according to db server port as on my pc

jdbc:postgresql://localhost:5432/postgres
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.