Thread: postgres- connection refuse

postgres- connection refuse

From
"Yang Soon Chiao"
Date:
This is my first time using postgres. Everything work fine when I use psql at the bin, however when I try to connect using java, I get this message.
 
Connection refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
 
- It seem like I have the problem with hostname and port but I don't know how to tune it. (I've modify my postgresql.conf set tcpip_socket = true but still cannot work).
 
- Here is how my code looks like
conn = DriverManager.getConnection("jdbc:postgresql:mydb","", "");
 
(I'm not connecting to any web server)
 
Please help and thanks in advance.
 

Re: postgres- connection refuse

From
Paul Thomas
Date:
On 09/09/2003 12:08 Yang Soon Chiao wrote:
> This is my first time using postgres. Everything work fine when I use
> psql at the bin, however when I try to connect using java, I get this
> message.
>
> Connection refused. Check that the hostname and port are correct and that
> the postmaster is accepting TCP/IP connections.
>
> - It seem like I have the problem with hostname and port but I don't know
> how to tune it. (I've modify my postgresql.conf set tcpip_socket = true
> but still cannot work).

Did you restart the postmaster?

>
> - Here is how my code looks like
> conn = DriverManager.getConnection("jdbc:postgresql:mydb","", "");
>
> (I'm not connecting to any web server)
>
> Please help and thanks in advance.
>

I'm sure if an empty userid will work (I've never tried it). What does
your pg_hba.conf say? Aslo what version of postgreSQL are you using?

--
Paul Thomas
+------------------------------+---------------------------------------------+
| Thomas Micro Systems Limited | Software Solutions for the Smaller
Business |
| Computer Consultants         |
http://www.thomas-micro-systems-ltd.co.uk   |
+------------------------------+---------------------------------------------+

Re: postgres- connection refuse

From
"Nick Fankhauser"
Date:
Since pgsql doesn't use a tcp/ip connection by default, it can work when a
network connection is not allowed.

To force pgsql to use tcp/ip for a connection, us the -h param:

psql -h <local.server.name> <dbname>

If you can't connect this way, then you should be looking at the pg_hba.conf
file. In particular, make sure you are set up well for localhost.

If you *can* connect this way, then you have the auth set up fine in pg_hba
and you should be looking for the problem in your JDBC code.

-Nick


-----Original Message-----
From: pgsql-jdbc-owner@postgresql.org
[mailto:pgsql-jdbc-owner@postgresql.org]On Behalf Of Yang Soon Chiao
Sent: Tuesday, September 09, 2003 6:09 AM
To: pgsql-jdbc@postgresql.org
Subject: [JDBC] postgres- connection refuse


This is my first time using postgres. Everything work fine when I use psql
at the bin, however when I try to connect using java, I get this message.

Connection refused. Check that the hostname and port are correct and that
the postmaster is accepting TCP/IP connections.

- It seem like I have the problem with hostname and port but I don't know
how to tune it. (I've modify my postgresql.conf set tcpip_socket = true but
still cannot work).

- Here is how my code looks like
conn = DriverManager.getConnection("jdbc:postgresql:mydb","", "");

(I'm not connecting to any web server)

Please help and thanks in advance.