0

Been at this for days i cant make a connection to my postgreSQL database on my local machine, running mac os ML.

nmap of my machine shows that postgres is running on 5432 and i can connect locally via pgadmin and psql.

pg_hba.conf file for postgres    
local   all             all                                     trust    
host    all             all             127.0.0.1/32           trust    
host    all             all             192.168.0.2/16            trust

listen address is set to *

I get the follwing exception when i try to connect with JDBC

org.postgresql.util.PSQLException: Connection refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.

6
  • Check if your client belongs to 192.168.0.2/16. Commented Jan 20, 2013 at 8:57
  • "jdbc:postgresql://localhost/lab2" Commented Jan 20, 2013 at 9:32
  • Yeah i am part of that range also thanks Commented Jan 20, 2013 at 9:33
  • Thought its also worth adding that i CANT connect via pg admin from a machine on my LAN. I also read somewhere that all JDBC connections go through tcp/ip not via the local host loopback, the thing is i cant get postgres to listen Commented Jan 20, 2013 at 9:39
  • Nevermind feel so stupid found the problem The listen address is commented out by default in postgres config and i didnt notice due to the line wrapping. Godammit. Sorry for wasting your time Commented Jan 20, 2013 at 9:46

1 Answer 1

1

In troubleshooting these sorts of problems check the following in order:

  1. Can you connect to PostgreSQL from another machine on the LAN? If not, it may not be listening on the address?

  2. Can you connect locally? Is it even running?

Now in the case where the second succeeds and the first fails, here are things to check in order:

  1. listen_address in postgresql.conf

  2. firewall rules

  3. Anything in between that might interfere with the network connections.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.