Lists: | pgsql-jdbc |
---|
From: | "Albretch Mueller" <lbrtchx(at)gmail(dot)com> |
---|---|
To: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | trying to connect to pg from within a local network |
Date: | 2008-01-16 14:22:19 |
Message-ID: | 9ef66fac0801160622k4e325c4cl7f5357a4df67ee2@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-jdbc |
// __ trying to connect from 10.0.31.62
~
Hi,
~
I need to connect to a pg Windows installation that I have within the
same network
~
as listen_address I have listed: localhost, 127.0.0.1, 10.0.31.5, 10.0.31.62
~
10.0.31.5 is this "localhost" in the 10.0.31.* local network and
10.0.31.62 is me
~
I have check all I can think of and it still does not work. Why can't
I connect to pg from within the local network?
~
Thanks
lbrtchx
~
C:\cmllpz\prjx\java\JDBC\PG>java PG00Test
// __ aDrvr: |org.postgresql.Driver|
// __ aDBURL: |jdbc:postgresql://10.0.31.5:5432/postgres|
// __ Class.forName(org.postgresql.Driver): |class org.postgresql.Driver|
// __ (Driver)KDrvr.newInstance() :|org(dot)postgresql(dot)Driver(at)1893efe|
// __ DriverManager.registerDriver(OKDrvr);
org.postgresql.util.PSQLException: Connection refused. Check that the
hostname and port are correct and that the postmaster is accepting
TCP/IP connections.
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:122)
at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:66)
at org.postgresql.jdbc2.AbstractJdbc2Connection.<init>(AbstractJdbc2Connection.java:125)
at org.postgresql.jdbc3.AbstractJdbc3Connection.<init>(AbstractJdbc3Connection.java:30)
at org.postgresql.jdbc4.AbstractJdbc4Connection.<init>(AbstractJdbc4Connection.java:18)
at org.postgresql.jdbc4.Jdbc4Connection.<init>(Jdbc4Connection.java:24)
at org.postgresql.Driver.makeConnection(Driver.java:382)
at org.postgresql.Driver.connect(Driver.java:260)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at PG00.<init>(PG00Test.java:26)
at PG00Test.main(PG00Test.java:213)
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:518)
at java.net.Socket.connect(Socket.java:468)
at java.net.Socket.<init>(Socket.java:365)
at java.net.Socket.<init>(Socket.java:179)
at org.postgresql.core.PGStream.<init>(PGStream.java:59)
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:77)
... 11 more
// __ database connection could not be set up!
C:\cmllpz\prjx\java\JDBC\PG>ipconfig -all
Windows IP Configuration
Host Name . . . . . . . . . . . . : BGN-2008
Primary Dns Suffix . . . . . . . : exchange.thetrade.org
Node Type . . . . . . . . . . . . : Unknown
IP Routing Enabled. . . . . . . . : No
WINS Proxy Enabled. . . . . . . . : No
DNS Suffix Search List. . . . . . : exchange.thetrade.org
thetrade.org
Ethernet adapter Local Area Connection:
Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : Broadcom 440x 10/100
Integrated Controller
Physical Address. . . . . . . . . : 00-16-E6-45E-F5-27
Dhcp Enabled. . . . . . . . . . . : Yes
Autoconfiguration Enabled . . . . : Yes
IP Address. . . . . . . . . . . . : 10.0.31.62
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 10.0.31.1
DHCP Server . . . . . . . . . . . : 10.0.31.1
DNS Servers . . . . . . . . . . . : 10.0.1.23
10.0.1.74
Lease Obtained. . . . . . . . . . : Tuesday, January 15, 2008 9:18:55 PM
Lease Expires . . . . . . . . . . : Wednesday, January 16,
2008 9:18:55 PM
C:\cmllpz\prjx\java\JDBC\PG>
~
C:\cmllpz\prjx\java\JDBC\PG>tracert 10.0.31.5
Tracing route to 10.0.31.5 over a maximum of 30 hops
1 <1 ms <1 ms <1 ms 10.0.31.5
Trace complete.
~
From: | "Albe Laurenz" <laurenz(dot)albe(at)wien(dot)gv(dot)at> |
---|---|
To: | "Albretch Mueller *EXTERN*" <lbrtchx(at)gmail(dot)com>, <pgsql-jdbc(at)postgresql(dot)org> |
Subject: | Re: trying to connect to pg from within a local network |
Date: | 2008-01-16 16:00:38 |
Message-ID: | D960CB61B694CF459DCFB4B0128514C2CC22D3@exadv11.host.magwien.gv.at |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-jdbc |
Albretch Mueller wrote:
> I need to connect to a pg Windows installation that I have within the
> same network
> ~
> as listen_address I have listed: localhost, 127.0.0.1,
> 10.0.31.5, 10.0.31.62
> ~
> 10.0.31.5 is this "localhost" in the 10.0.31.* local network and
> 10.0.31.62 is me
> ~
> I have check all I can think of and it still does not work. Why can't
> I connect to pg from within the local network?
> ~
> Thanks
> lbrtchx
> ~
> C:\cmllpz\prjx\java\JDBC\PG>java PG00Test
> // __ aDrvr: |org.postgresql.Driver|
> // __ aDBURL: |jdbc:postgresql://10.0.31.5:5432/postgres|
> // __ Class.forName(org.postgresql.Driver): |class org.postgresql.Driver|
> // __ (Driver)KDrvr.newInstance() :|org(dot)postgresql(dot)Driver(at)1893efe|
> // __ DriverManager.registerDriver(OKDrvr);
> org.postgresql.util.PSQLException: Connection refused. Check that the
> hostname and port are correct and that the postmaster is accepting
> TCP/IP connections.
> at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:122)
You should have the following in postgresql.conf:
listen_addresses = '127.0.0.1,10.0.31.5'
Maybe the last entry you added is the problem.
Allowing certain client IP addresses is done in pg_hba.conf.
If that is NOT the problem:
Try the following on the client:
telnet 10.0.31.5 5432
and tell us the response.
Try the following on the server:
netstat -a
and tell us what you get.
Is there a firewall involved?
Yours,
Laurenz Albe
From: | "Albretch Mueller" <lbrtchx(at)gmail(dot)com> |
---|---|
To: | pgsql-jdbc(at)postgresql(dot)org, "Albe Laurenz" <laurenz(dot)albe(at)wien(dot)gv(dot)at> |
Subject: | Re: trying to connect to pg from within a local network |
Date: | 2008-01-16 17:58:58 |
Message-ID: | 9ef66fac0801160958x20ee181ejcfb6f54c45b1be35@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-jdbc |
> You should have the following in postgresql.conf: listen_addresses = '127.0.0.1,10.0.31.5'
~
I did change it
~
> Allowing certain client IP addresses is done in pg_hba.conf.
~
OK, I did too, this is how my /data/pg_hba.conf looks like:
~
# TYPE DATABASE USER CIDR-ADDRESS METHOD
# IPv4 local connections:
host all all 127.0.0.1/32,10.0.31.62 md5
# IPv6 local connections:
#host all all ::1/128 md5
~
> Try the following on the client: telnet 10.0.31.5 5432
~
C:\>telnet 10.0.31.5 5432
Connecting To 10.0.31.5...Could not open connection to the host, on
port 5432: Connect failed
C:\>ping 10.0.31.5
Pinging 10.0.31.5 with 32 bytes of data:
Reply from 10.0.31.5: bytes=32 time<1ms TTL=128
Reply from 10.0.31.5: bytes=32 time<1ms TTL=128
Reply from 10.0.31.5: bytes=32 time<1ms TTL=128
Reply from 10.0.31.5: bytes=32 time<1ms TTL=128
Ping statistics for 10.0.31.5:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms
~
> Try the following on the server: netstat -a
~
on the server:
~
C:\Documents and Settings\Administrator>netstat -a
Active Connections
Proto Local Address Foreign Address State
TCP BNG-04:epmap BNG-04.exchange.goodwillny.org:0 LISTENING
TCP BNG-04:microsoft-ds BNG-04.exchange.goodwillny.org:0 LISTENING
TCP BNG-04:1043 BNG-04.exchange.goodwillny.org:0 LISTENING
TCP BNG-04:3389 BNG-04.exchange.goodwillny.org:0 LISTENING
TCP BNG-04:4899 BNG-04.exchange.goodwillny.org:0 LISTENING
TCP BNG-04:netbios-ssn BNG-04.exchange.goodwillny.org:0 LISTENING
TCP BNG-04:1059 10.0.31.5:microsoft-ds ESTABLISHED
TCP BNG-04:1048 BNG-04.exchange.goodwillny.org:0 LISTENING
TCP BNG-04:1093 localhost:5432 ESTABLISHED
TCP BNG-04:5432 BNG-04.exchange.goodwillny.org:0 LISTENING
TCP BNG-04:5432 localhost:1093 ESTABLISHED
UDP BNG-04:microsoft-ds *:*
UDP BNG-04:isakmp *:*
UDP BNG-04:1025 *:*
UDP BNG-04:1026 *:*
UDP BNG-04:1058 *:*
UDP BNG-04:2967 *:*
UDP BNG-04:4500 *:*
UDP BNG-04:ntp *:*
UDP BNG-04:netbios-ns *:*
UDP BNG-04:netbios-dgm *:*
UDP BNG-04:1900 *:*
UDP BNG-04:ntp *:*
UDP BNG-04:1028 *:*
UDP BNG-04:1041 *:*
UDP BNG-04:1900 *:*
~
> Is there a firewall involved?
~
Not from my box, which is a client to pg
~
//__ "netstat -a" on my client box
C:\>netstat -a
Active Connections
Proto Local Address Foreign Address State
TCP BNG-2008:microsoft-ds BNG-2008.exchange.goodwillny.org:0 LISTENING
TCP BNG-2008:netbios-ssn BNG-2008.exchange.goodwillny.org:0 LISTENING
TCP BNG-2008:1144 gwdcbke1.exchange.goodwillny.org:1025 ESTABLISHED
TCP BNG-2008:1152 10.0.31.5:netbios-ssn ESTABLISHED
TCP BNG-2008:1262 mailserver.exchange.goodwillny.org:2128 ESTABLISHED
TCP BNG-2008:1341 exchange-i.exchange.goodwillny.org:9090 CLOSE_WAIT
TCP BNG-2008:1342 exchange-i.exchange.goodwillny.org:9090 CLOSE_WAIT
TCP BNG-2008:1396 exchange-i.exchange.goodwillny.org:9090 ESTABLISHED
TCP BNG-2008:1408 exchange-i.exchange.goodwillny.org:9090 ESTABLISHED
TCP BNG-2008:1044 BNG-2008.exchange.goodwillny.org:0 LISTENING
TCP BNG-2008:1153 localhost:1154 ESTABLISHED
TCP BNG-2008:1154 localhost:1153 ESTABLISHED
TCP BNG-2008:1155 localhost:1156 ESTABLISHED
TCP BNG-2008:1156 localhost:1155 ESTABLISHED
TCP BNG-2008:5432 BNG-2008.exchange.goodwillny.org:0 LISTENING
UDP BNG-2008:microsoft-ds *:*
UDP BNG-2008:isakmp *:*
UDP BNG-2008:1025 *:*
UDP BNG-2008:1026 *:*
UDP BNG-2008:1145 *:*
UDP BNG-2008:2967 *:*
UDP BNG-2008:4500 *:*
UDP BNG-2008:ntp *:*
UDP BNG-2008:netbios-ns *:*
UDP BNG-2008:netbios-dgm *:*
UDP BNG-2008:1900 *:*
UDP BNG-2008:ntp *:*
UDP BNG-2008:1029 *:*
UDP BNG-2008:1031 *:*
UDP BNG-2008:1042 *:*
UDP BNG-2008:1058 *:*
UDP BNG-2008:1900 *:*
From: | Jan de Visser <jdevisser(at)digitalfairway(dot)com> |
---|---|
To: | pgsql-jdbc(at)postgresql(dot)org |
Cc: | "Albretch Mueller" <lbrtchx(at)gmail(dot)com>, "Albe Laurenz" <laurenz(dot)albe(at)wien(dot)gv(dot)at> |
Subject: | Re: ***SPAM*** Re: trying to connect to pg from within a local network |
Date: | 2008-01-16 18:54:12 |
Message-ID: | 200801161354.12290.jdevisser@digitalfairway.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-jdbc |
On Wednesday 16 January 2008 12:58:58 Albretch Mueller wrote:
> OK, I did too, this is how my /data/pg_hba.conf looks like:
> ~
> # TYPE DATABASE USER CIDR-ADDRESS METHOD
>
> # IPv4 local connections:
> host all all 127.0.0.1/32,10.0.31.62 md5
> # IPv6 local connections:
> #host all all ::1/128 md5
It doesn't work like that. CIDR-ADDRESS is a single address range.
Try putting 10.0.31.62/32 on a separate line.
jan
--
--------------------------------------------------------------
Jan de Visser jdevisser(at)digitalfairway(dot)com
Baruk Khazad! Khazad ai-menu!
--------------------------------------------------------------
From: | "Albretch Mueller" <lbrtchx(at)gmail(dot)com> |
---|---|
To: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | Re: trying to connect to pg from within a local network |
Date: | 2008-01-16 18:59:16 |
Message-ID: | 9ef66fac0801161059i624d6cadt5d72e15d22f0d13c@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-jdbc |
Now, I am also getting "connection refused" messages even though I do
know tc is running since I can check it with pdAdmin3
~
~
org.postgresql.util.PSQLException: Connection refused. Check that the
hostname and port are correct and that the postmaster is accepting
TCP/IP connections.
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:122)
at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:66)
at org.postgresql.jdbc2.AbstractJdbc2Connection.<init>(AbstractJdbc2Connection.java:125)
at org.postgresql.jdbc3.AbstractJdbc3Connection.<init>(AbstractJdbc3Connection.java:30)
at org.postgresql.jdbc4.AbstractJdbc4Connection.<init>(AbstractJdbc4Connection.java:18)
at org.postgresql.jdbc4.Jdbc4Connection.<init>(Jdbc4Connection.java:24)
at org.postgresql.Driver.makeConnection(Driver.java:382)
at org.postgresql.Driver.connect(Driver.java:260)
at org.apache.catalina.realm.JDBCRealm.open(JDBCRealm.java:649)
at org.apache.catalina.realm.JDBCRealm.start(JDBCRealm.java:713)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:3620)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1148)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:697)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1148)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:311)
at org.apache.catalina.core.StandardService.start(StandardService.java:450)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:2213)
at org.apache.catalina.startup.Catalina.start(Catalina.java:459)
at org.apache.catalina.startup.Catalina.execute(Catalina.java:346)
at org.apache.catalina.startup.Catalina.process(Catalina.java:130)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:151)
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:518)
at java.net.Socket.connect(Socket.java:468)
at java.net.Socket.<init>(Socket.java:365)
at java.net.Socket.<init>(Socket.java:179)
at org.postgresql.core.PGStream.<init>(PGStream.java:59)
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:77)
... 24 more
~
and this is the part that matters in my server.xml file:
~
<Context path="/fileupload"
docBase="Z:\BEGIN\ESL\RLopez\GWB\prjx\GWB02\webapps12\fileupload"
debug="4"
reloadable="true"
crossContext="true"
workDir="Z:\BEGIN\ESL\RLopez\GWB\prjx\tc-4.1.36_workDir"
swallowOutput="true">
<Logger className="org.apache.catalina.logger.FileLogger"
directory="Z:\BEGIN\ESL\RLopez\GWB\prjx\logs"
prefix="tc-4.1.36_localhost_FileUpload_log."
suffix=".txt"
timestamp="true"/>
<Realm className="org.apache.catalina.realm.JDBCRealm"
driverName="org.postgresql.Driver"
connectionURL="jdbc:postgresql://10.0.31.5/postgres"
connectionName="postgres"
connectionPassword="gwbpsswrd"
userTable="users"
userNameCol="user_name"
userCredCol="user_pass"
userRoleTable="user_roles" roleNameCol="role_name"/>
</Context>
~
From: | Jan de Visser <jdevisser(at)digitalfairway(dot)com> |
---|---|
To: | pgsql-jdbc(at)postgresql(dot)org |
Cc: | "Albretch Mueller" <lbrtchx(at)gmail(dot)com>, "Albe Laurenz" <laurenz(dot)albe(at)wien(dot)gv(dot)at> |
Subject: | Re: trying to connect to pg from within a local network |
Date: | 2008-01-16 19:06:32 |
Message-ID: | 200801161406.32449.jdevisser@digitalfairway.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-jdbc |
On Wednesday 16 January 2008 12:58:58 Albretch Mueller wrote:
> OK, I did too, this is how my /data/pg_hba.conf looks like:
> ~
> # TYPE DATABASE USER CIDR-ADDRESS METHOD
>
> # IPv4 local connections:
> host all all 127.0.0.1/32,10.0.31.62 md5
> # IPv6 local connections:
> #host all all ::1/128 md5
It doesn't work like that. CIDR-ADDRESS is a single address range.
Try putting 10.0.31.62/32 on a separate line.
jan
--
--------------------------------------------------------------
Jan de Visser jdevisser(at)digitalfairway(dot)com
Baruk Khazad! Khazad ai-menu!
--------------------------------------------------------------
From: | "Albe Laurenz" <laurenz(dot)albe(at)wien(dot)gv(dot)at> |
---|---|
To: | "Albretch Mueller *EXTERN*" <lbrtchx(at)gmail(dot)com>, <pgsql-jdbc(at)postgresql(dot)org> |
Subject: | Re: trying to connect to pg from within a local network |
Date: | 2008-01-17 15:46:26 |
Message-ID: | D960CB61B694CF459DCFB4B0128514C2CC25C6@exadv11.host.magwien.gv.at |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-jdbc |
Albretch Mueller wrote:
> Now, I am also getting "connection refused" messages even though I do
> know tc is running since I can check it with pdAdmin3
>
> org.postgresql.util.PSQLException: Connection refused. Check that the
> hostname and port are correct and that the postmaster is accepting
> TCP/IP connections.
Bad. pgAdmin3 runs on the server, right?
So local connections are possible. Good to know.
>> You should have the following in postgresql.conf:
>> listen_addresses = '127.0.0.1,10.0.31.5'
>
> I did change it
Good.
>> Allowing certain client IP addresses is done in pg_hba.conf.
>
> OK, I did too, this is how my /data/pg_hba.conf looks like:
>
> # TYPE DATABASE USER CIDR-ADDRESS METHOD
>
> # IPv4 local connections:
> host all all 127.0.0.1/32,10.0.31.62 md5
> # IPv6 local connections:
> #host all all ::1/128 md5
That is not correct, you should have entries like this:
host all all 127.0.0.1/32 md5
host all all 10.0.31.62/32 md5
host all all 0.0.0.0/0 reject
But that should not lead to a "connection refused" message like you
encounter, but to a "there is no pg_hba.conf entry" message.
So that is not the immediate problem, though it will become later on.
>> Try the following on the client: telnet 10.0.31.5 5432
>
> C:\>telnet 10.0.31.5 5432
> Connecting To 10.0.31.5...Could not open connection to the host, on
> port 5432: Connect failed
That means that either
a) the PostgreSQL server is not listening on this port
or
b) a firewall blocks you.
>> Try the following on the server: netstat -a
>
> on the server:
>
> C:\Documents and Settings\Administrator>netstat -a
>
> Active Connections
>
> Proto Local Address Foreign Address State
[...]
> TCP BNG-04:5432 BNG-04.exchange.goodwillny.org:0 LISTENING
[...]
OK, that's your PostgreSQL server listening.
> > Is there a firewall involved?
>
> Not from my box, which is a client to pg
The firewall could also be somewhere between your client and the server.
> //__ "netstat -a" on my client box
> C:\>netstat -a
>
> Active Connections
>
> Proto Local Address Foreign Address State
[...]
> TCP BNG-2008:1152 10.0.31.5:netbios-ssn ESTABLISHED
[...]
That at least shows that it is possible to get TCP connections from
your client to the server. At least on port 139.
Could still be that a firewall blocks other ports.
Ok, let's sum up:
- Your server is up and running (you can connect locally).
- Your server is listening on port 5432.
- You cannot open a TCP connection from client to server on port 5432
(but on port 139 you can).
That looks too me like a network/firewall problem.
I know too little about networks, particularly on Windows, to tell you
how to proceed.
But to confirm my suspicion, there's a few things you can try:
- From the client, try "telnet 10.0.31.5 139".
That should not give you an error message.
- From the server, try "telnet 10.0.31.5 5432".
That should also not give you an error message.
If these two work, but "telnet 10.0.31.5 5432" from the client
gives you a "connection refused", I don't know whom to blame but
the network configuration.
Yours,
Laurenz Albe
From: | Mark Lewis <mark(dot)lewis(at)mir3(dot)com> |
---|---|
To: | Albe Laurenz <laurenz(dot)albe(at)wien(dot)gv(dot)at> |
Cc: | Albretch Mueller *EXTERN* <lbrtchx(at)gmail(dot)com>, pgsql-jdbc(at)postgresql(dot)org |
Subject: | Re: trying to connect to pg from within a local network |
Date: | 2008-01-17 16:06:24 |
Message-ID: | 1200585984.15326.456.camel@archimedes |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-jdbc |
If the server is running on Windows, all recent versions of Windows run
a built-in firewall by default that will block remote access to the PG
port. Have you confirmed that the firewall is either not running, or
has an exception for the PG port?
-- Mark Lewis
On Thu, 2008-01-17 at 16:46 +0100, Albe Laurenz wrote:
> Albretch Mueller wrote:
>
> > Now, I am also getting "connection refused" messages even though I do
> > know tc is running since I can check it with pdAdmin3
> >
> > org.postgresql.util.PSQLException: Connection refused. Check that the
> > hostname and port are correct and that the postmaster is accepting
> > TCP/IP connections.
>
> Bad. pgAdmin3 runs on the server, right?
> So local connections are possible. Good to know.
>
> >> You should have the following in postgresql.conf:
> >> listen_addresses = '127.0.0.1,10.0.31.5'
> >
> > I did change it
>
> Good.
>
> >> Allowing certain client IP addresses is done in pg_hba.conf.
> >
> > OK, I did too, this is how my /data/pg_hba.conf looks like:
> >
> > # TYPE DATABASE USER CIDR-ADDRESS METHOD
> >
> > # IPv4 local connections:
> > host all all 127.0.0.1/32,10.0.31.62 md5
> > # IPv6 local connections:
> > #host all all ::1/128 md5
>
> That is not correct, you should have entries like this:
>
> host all all 127.0.0.1/32 md5
> host all all 10.0.31.62/32 md5
> host all all 0.0.0.0/0 reject
>
> But that should not lead to a "connection refused" message like you
> encounter, but to a "there is no pg_hba.conf entry" message.
>
> So that is not the immediate problem, though it will become later on.
>
> >> Try the following on the client: telnet 10.0.31.5 5432
> >
> > C:\>telnet 10.0.31.5 5432
> > Connecting To 10.0.31.5...Could not open connection to the host, on
> > port 5432: Connect failed
>
> That means that either
> a) the PostgreSQL server is not listening on this port
> or
> b) a firewall blocks you.
>
> >> Try the following on the server: netstat -a
> >
> > on the server:
> >
> > C:\Documents and Settings\Administrator>netstat -a
> >
> > Active Connections
> >
> > Proto Local Address Foreign Address State
> [...]
> > TCP BNG-04:5432 BNG-04.exchange.goodwillny.org:0 LISTENING
> [...]
>
> OK, that's your PostgreSQL server listening.
>
> > > Is there a firewall involved?
> >
> > Not from my box, which is a client to pg
>
> The firewall could also be somewhere between your client and the server.
>
> > //__ "netstat -a" on my client box
> > C:\>netstat -a
> >
> > Active Connections
> >
> > Proto Local Address Foreign Address State
> [...]
> > TCP BNG-2008:1152 10.0.31.5:netbios-ssn ESTABLISHED
> [...]
>
> That at least shows that it is possible to get TCP connections from
> your client to the server. At least on port 139.
> Could still be that a firewall blocks other ports.
>
>
> Ok, let's sum up:
>
> - Your server is up and running (you can connect locally).
> - Your server is listening on port 5432.
> - You cannot open a TCP connection from client to server on port 5432
> (but on port 139 you can).
>
> That looks too me like a network/firewall problem.
> I know too little about networks, particularly on Windows, to tell you
> how to proceed.
>
> But to confirm my suspicion, there's a few things you can try:
>
> - From the client, try "telnet 10.0.31.5 139".
> That should not give you an error message.
>
> - From the server, try "telnet 10.0.31.5 5432".
> That should also not give you an error message.
>
> If these two work, but "telnet 10.0.31.5 5432" from the client
> gives you a "connection refused", I don't know whom to blame but
> the network configuration.
>
> Yours,
> Laurenz Albe
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faq
From: | "Albretch Mueller" <lbrtchx(at)gmail(dot)com> |
---|---|
To: | "Mark Lewis" <mark(dot)lewis(at)mir3(dot)com>, pgsql-jdbc(at)postgresql(dot)org |
Subject: | Re: trying to connect to pg from within a local network |
Date: | 2008-01-18 17:13:50 |
Message-ID: | 9ef66fac0801180913p3ecf6861u1262c83303178de3@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-jdbc |
~
Well, I went:
~
Start > Control Panel > Windows Firewall
~
and it is: "off (not recommended)"
~
Something I still am not sure about is how to:
~
"Check that the hostname and port are correct and that the postmaster
is accepting TCP/IP connnections"
~
There is nothing I can see in pg_hba.conf or postgres.conf that
relates to TCP/IP connnections and I think it is a pg thing, because
when I run tomcat on port 8080 on this box, I can telnet to it without
any problems
~
Tomcat is using a pg-based JDBCRealm, that means it is connecting to
it without any problems
~
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ FROM client~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
C:\>ipconfig -all
Windows IP Configuration
Host Name . . . . . . . . . . . . : BKN-2008
Primary Dns Suffix . . . . . . . : thetrade.com
Node Type . . . . . . . . . . . . : Unknown
IP Routing Enabled. . . . . . . . : No
WINS Proxy Enabled. . . . . . . . : No
DNS Suffix Search List. . . . . . : thetrade.com
thetrade
Ethernet adapter Local Area Connection:
Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : Broadcom 440x 10/100
Integrated Controller
Physical Address. . . . . . . . . : 00-16-45-0E-F5-27
Dhcp Enabled. . . . . . . . . . . : Yes
Autoconfiguration Enabled . . . . : Yes
IP Address. . . . . . . . . . . . : 10.0.31.62
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 10.0.31.1
DHCP Server . . . . . . . . . . . : 10.0.31.1
DNS Servers . . . . . . . . . . . : 10.0.1.23
10.0.1.74
Lease Obtained. . . . . . . . . . : Friday, January 18, 2008 9:34:04 AM
Lease Expires . . . . . . . . . . : Saturday, January 19, 2008
9:34:04 AM
C:\>telnet bkn-04 5432
Connecting To bkn-04...Could not open connection to the host, on port
5432: Connect failed
C:\>telnet 10.0.31.88 5432
Connecting To 10.0.31.88...Could not open connection to the host, on
port 5432: Connect failed
~
C:\>telnet bkn-04 8080
(connects OK)
~
C:\>telnet 10.0.31.88 8080
(connects OK)
~
C:\cmllpz\prjx\java\JDBC\PG>java PG00Test
// __ aDrvr: |org.postgresql.Driver|
// __ aDBURL: |jdbc:postgresql://bkn-04:5432/postgres|
// __ Class.forName(org.postgresql.Driver): |class org.postgresql.Driver|
// __ (Driver)KDrvr.newInstance() :|org(dot)postgresql(dot)Driver(at)1893efe|
// __ DriverManager.registerDriver(OKDrvr);
org.postgresql.util.PSQLException: Connection refused. Check that the
hostname and port are correct and that the postmaster is accepting
TCP/IP con
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:122)
at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:66)
at org.postgresql.jdbc2.AbstractJdbc2Connection.<init>(AbstractJdbc2Connection.java:125)
at org.postgresql.jdbc3.AbstractJdbc3Connection.<init>(AbstractJdbc3Connection.java:30)
at org.postgresql.jdbc4.AbstractJdbc4Connection.<init>(AbstractJdbc4Connection.java:18)
at org.postgresql.jdbc4.Jdbc4Connection.<init>(Jdbc4Connection.java:24)
at org.postgresql.Driver.makeConnection(Driver.java:382)
at org.postgresql.Driver.connect(Driver.java:260)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at PG00.<init>(PG00Test.java:26)
at PG00Test.main(PG00Test.java:213)
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:518)
at java.net.Socket.connect(Socket.java:468)
at java.net.Socket.<init>(Socket.java:365)
at java.net.Socket.<init>(Socket.java:179)
at org.postgresql.core.PGStream.<init>(PGStream.java:59)
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:77)
... 11 more
// __ database connection could not be set up!
From: | "Mike C(dot)" <mcbp223(at)yahoo(dot)com> |
---|---|
To: | Albretch Mueller <lbrtchx(at)gmail(dot)com>, pgsql-jdbc(at)postgresql(dot)org |
Subject: | Re: trying to connect to pg from within a local network |
Date: | 2008-01-18 22:58:18 |
Message-ID: | 45764.67573.qm@web61312.mail.yahoo.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-jdbc |
On my Solaris box, which btw is really picky about security, here is how my config looks like, note that I have two ethernet interfaces on it, dn-2xe32-iprb0 and dn-2xe32-e1000g0.
Also my local network is on 192.168.1.0.
postgresql.conf
----------------------
# - Connection Settings -
listen_addresses = 'localhost, dn-2xe32-e1000g0'
# what IP address(es) to listen on;
# comma-separated list of addresses;
# defaults to 'localhost', '*' = all
# (change requires restart)
port = 5432 # (change requires restart)
-----------------
pg_hba.conf
-----------------
# IPv4 local connections:
host all all 127.0.0.1/32 trust
host all postgres 192.168.1.0/24 md5
host all pguser2 192.168.1.0/24 md5
-----------------
Also I have seen in your first email an entry listen_address instead of listen_addresses, can you double check if there is no spelling error somewhere, you never know.
Did you try listen_addresses='*' and see if that would listen more than localhost?
Mike
Albretch Mueller <lbrtchx(at)gmail(dot)com> wrote:
There is nothing I can see in pg_hba.conf or postgres.conf that
relates to TCP/IP connnections and I think it is a pg thing, because
when I run tomcat on port 8080 on this box, I can telnet to it without
any problems
~
---------------------------------
Never miss a thing. Make Yahoo your homepage.
From: | "Albe Laurenz" <laurenz(dot)albe(at)wien(dot)gv(dot)at> |
---|---|
To: | "Albretch Mueller *EXTERN*" <lbrtchx(at)gmail(dot)com>, "Mark Lewis" <mark(dot)lewis(at)mir3(dot)com>, <pgsql-jdbc(at)postgresql(dot)org> |
Subject: | Re: trying to connect to pg from within a local network |
Date: | 2008-01-21 08:27:20 |
Message-ID: | D960CB61B694CF459DCFB4B0128514C2CC2A84@exadv11.host.magwien.gv.at |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-jdbc |
Albretch Mueller wrote:
> Start > Control Panel > Windows Firewall
>
> and it is: "off (not recommended)"
Did you make sure that there is no firewall ON the server
and no firewall BETWEEN the client and the server?
> C:\>telnet bkn-04 5432
> Connecting To bkn-04...Could not open connection to the host, on port
> 5432: Connect failed
Did you try this on the client machine or on the server machine?
Does the result differ on both?
> C:\>telnet 10.0.31.88 5432
> Connecting To 10.0.31.88...Could not open connection to the host, on
> port 5432: Connect failed
> ~
> C:\>telnet bkn-04 8080
> (connects OK)
> ~
> C:\>telnet 10.0.31.88 8080
> (connects OK)
Since the "netstat" output you posted before showed something listening
on port 5432 on the server machine, it still looks like a network or
firewall problem.
Have you talked to the people who manage your network?
Yours,
Laurenz Albe