Unix Technical Forum

SEO

vBulletin Search Engine Optimization


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Interfaces jdbc

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-16-2008, 12:59 AM
Albretch Mueller
 
Posts: n/a
Default trying to connect to pg from within a local network

// __ 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: |jdbcostgresql://10.0.31.5:5432/postgres|
// __ Class.forName(org.postgresql.Driver): |class org.postgresql.Driver|
// __ (Driver)KDrvr.newInstance() :|org.postgresql.Driver@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.openC onnectionImpl(ConnectionFactoryImpl.java:122)
at org.postgresql.core.ConnectionFactory.openConnecti on(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>(Jdbc4C onnection.java:24)
at org.postgresql.Driver.makeConnection(Driver.java:3 82)
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(PlainSoc ketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.j ava:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.j ava: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.openC onnectionImpl(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.
~

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-16-2008, 12:59 AM
Albe Laurenz
 
Posts: n/a
Default Re: trying to connect to pg from within a local network

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: |jdbcostgresql://10.0.31.5:5432/postgres|
> // __ Class.forName(org.postgresql.Driver): |class org.postgresql.Driver|
> // __ (Driver)KDrvr.newInstance() :|org.postgresql.Driver@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.openC onnectionImpl(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

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-16-2008, 12:59 AM
Albretch Mueller
 
Posts: n/a
Default Re: trying to connect to pg from within a local network

> 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 *:*

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-16-2008, 12:59 AM
Jan de Visser
 
Posts: n/a
Default Re: ***SPAM*** Re: trying to connect to pg from within a local network

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@digitalfairway.com

* * * * * * * * Baruk Khazad! Khazad ai-menu!
--------------------------------------------------------------

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-16-2008, 12:59 AM
Albretch Mueller
 
Posts: n/a
Default Re: trying to connect to pg from within a local network

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.openC onnectionImpl(ConnectionFactoryImpl.java:122)
at org.postgresql.core.ConnectionFactory.openConnecti on(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>(Jdbc4C onnection.java:24)
at org.postgresql.Driver.makeConnection(Driver.java:3 82)
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(JDBCReal m.java:713)
at org.apache.catalina.core.StandardContext.start(Sta ndardContext.java:3620)
at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1148)
at org.apache.catalina.core.StandardHost.start(Standa rdHost.java:697)
at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1148)
at org.apache.catalina.core.StandardEngine.start(Stan dardEngine.java:311)
at org.apache.catalina.core.StandardService.start(Sta ndardService.java:450)
at org.apache.catalina.core.StandardServer.start(Stan dardServer.java:2213)
at org.apache.catalina.startup.Catalina.start(Catalin a.java:459)
at org.apache.catalina.startup.Catalina.execute(Catal ina.java:346)
at org.apache.catalina.startup.Catalina.process(Catal ina.java:130)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.main(Bootstr ap.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(PlainSoc ketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.j ava:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.j ava: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.openC onnectionImpl(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\webapp s12\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="jdbcostgresql://10.0.31.5/postgres"
connectionName="postgres"
connectionPassword="gwbpsswrd"
userTable="users"
userNameCol="user_name"
userCredCol="user_pass"
userRoleTable="user_roles" roleNameCol="role_name"/>

</Context>
~

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 04-16-2008, 12:59 AM
Jan de Visser
 
Posts: n/a
Default Re: trying to connect to pg from within a local network

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@digitalfairway.com

* * * * * * * * Baruk Khazad! Khazad ai-menu!
--------------------------------------------------------------

---------------------------(end of broadcast)---------------------------
TIP 7: You can help support the PostgreSQL project by donating at

http://www.postgresql.org/about/donate

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 04-16-2008, 12:59 AM
Albe Laurenz
 
Posts: n/a
Default Re: trying to connect to pg from within a local network

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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 04-16-2008, 12:59 AM
Mark Lewis
 
Posts: n/a
Default Re: trying to connect to pg from within a local network

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


---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 04-16-2008, 12:59 AM
Albretch Mueller
 
Posts: n/a
Default Re: trying to connect to pg from within a local network

~
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: |jdbcostgresql://bkn-04:5432/postgres|
// __ Class.forName(org.postgresql.Driver): |class org.postgresql.Driver|
// __ (Driver)KDrvr.newInstance() :|org.postgresql.Driver@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.openC onnectionImpl(ConnectionFactoryImpl.java:122)
at org.postgresql.core.ConnectionFactory.openConnecti on(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>(Jdbc4C onnection.java:24)
at org.postgresql.Driver.makeConnection(Driver.java:3 82)
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(PlainSoc ketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.j ava:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.j ava: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.openC onnectionImpl(ConnectionFactoryImpl.java:77)
... 11 more
// __ database connection could not be set up!

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 04-16-2008, 12:59 AM
Mike C.
 
Posts: n/a
Default Re: trying to connect to pg from within a local network

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@gmail.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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 02:05 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439