Dark Knight
Dark Knight

Reputation: 503

Connected to Postgresql error

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!

Upvotes: 1

Views: 3161

Answers (1)

Pankaj Sharma
Pankaj Sharma

Reputation: 1853

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

Upvotes: 2

Related Questions