Thread: Postgres-JDBC question
I am using Hibernate to connect to my PostgreSQL (btw – I love) database, and can connect my app and the db when using localhost, but when I try to connect via an ip address, it blows up telling me that the connection was refused. I have set the postmaster to listen for TCP/IP connections, but still does not work. Any suggestions?
Thanks,
Sean
This usually means that you have allowed TCP/IP connections in postgresql.conf, but haven't added a rule allowing remote access in pg_hba.conf for anything other than localhost. A sample pg_hba.conf line to allow any host on the network to connect using MD5 password hashes would be: host all all 0.0.0.0 0.0.0.0 md5 -- Mark Lewis On Fri, 2006-01-27 at 08:31 -0600, Sean wrote: > I am using Hibernate to connect to my PostgreSQL (btw – I love) > database, and can connect my app and the db when using localhost, but > when I try to connect via an ip address, it blows up telling me that > the connection was refused. I have set the postmaster to listen for > TCP/IP connections, but still does not work. Any suggestions? > > > > Thanks, > > Sean > >
On Sat, 28 Jan 2006 01:31 am, Sean wrote: > and can connect my app and the db when using localhost, but when I try to > connect via an ip address, it blows up telling me that the connection was > refused. I have set the postmaster to listen for TCP/IP connections, but > still does not work. Any suggestions? In postgresql.conf, the default config is to listen only on localhost IP address (probably listen_addresses will be set to default value and commented out). Change it so that is reads: listen_addresses = '*' and re-start the DB. As Mark mentioned, you may also want to review your pg_hba.conf file. Regards, Philip. -- "Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." - Brian W. Kernighan ----------------- Utiba Pty Ltd This message has been scanned for viruses and dangerous content by Utiba mail server and is believed to be clean.
Mark Lewis <mark.lewis 'at' mir3.com> writes: > This usually means that you have allowed TCP/IP connections in > postgresql.conf, but haven't added a rule allowing remote access in > pg_hba.conf for anything other than localhost. Sean - on Linux, you can check this with the following command: [root@meuh ~] netstat -ltpn Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:5432 0.0.0.0:* LISTEN 3310/postmaster ^^^ my postgres is listening on all addresses [...] tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 3259/master ^^^ my postfix is listening on localhost only -- Guillaume Cottenceau
Guillaume, On my host if I run netstat I see the following: tcp 0 0 0.0.0.0:5432 0.0.0.0:* LISTEN 5557/postmaster tcp 0 0 :::5432 :::* LISTEN 5557/postmaster Do those mean that my database must be accessible from the outside? I have access from localhost processes, but my attempts to connect to the database with pgAdmin failed. Andrey -----Original Message----- From: pgsql-jdbc-owner@postgresql.org [mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of Guillaume Cottenceau Sent: Monday, January 30, 2006 12:52 PM To: Sean; pgsql-jdbc@postgresql.org Subject: Re: [JDBC] Postgres-JDBC question Mark Lewis <mark.lewis 'at' mir3.com> writes: > This usually means that you have allowed TCP/IP connections in > postgresql.conf, but haven't added a rule allowing remote access in > pg_hba.conf for anything other than localhost. Sean - on Linux, you can check this with the following command: [root@meuh ~] netstat -ltpn Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:5432 0.0.0.0:* LISTEN 3310/postmaster ^^^ my postgres is listening on all addresses [...] tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 3259/master ^^^ my postfix is listening on localhost only -- Guillaume Cottenceau ---------------------------(end of broadcast)--------------------------- TIP 3: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faq
"Myatluk Andrey" <Andrey.Myatluk@bercut.ru> writes: > On my host if I run netstat I see the following: > tcp 0 0 0.0.0.0:5432 0.0.0.0:* > LISTEN 5557/postmaster > tcp 0 0 :::5432 :::* > LISTEN 5557/postmaster > Do those mean that my database must be accessible from the outside? I > have access from localhost processes, but my attempts to connect to the > database with pgAdmin failed. Failed how, exactly? The netstat output shows that the postmaster is listening for connections from anyplace, so you have listen_addresses set properly ... but there are at least two other levels where an attempted connection might be blocked: kernel packet filtering, or the contents of pg_hba.conf. What error message are you getting *exactly*? regards, tom lane
Did you have some firewall running on your PC? Takeichi. On 2/1/06, Tom Lane <tgl@sss.pgh.pa.us> wrote: > "Myatluk Andrey" <Andrey.Myatluk@bercut.ru> writes: > > On my host if I run netstat I see the following: > > > tcp 0 0 0.0.0.0:5432 0.0.0.0:* > > LISTEN 5557/postmaster > > > tcp 0 0 :::5432 :::* > > LISTEN 5557/postmaster > > > Do those mean that my database must be accessible from the outside? I > > have access from localhost processes, but my attempts to connect to the > > database with pgAdmin failed. > > Failed how, exactly? The netstat output shows that the postmaster is > listening for connections from anyplace, so you have listen_addresses > set properly ... but there are at least two other levels where an > attempted connection might be blocked: kernel packet filtering, or the > contents of pg_hba.conf. What error message are you getting *exactly*? > > regards, tom lane > > ---------------------------(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 >