Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

On Ubuntu 12.04, I've installed pg and pgadmin.

I can access localhost/phppgadmin using the browser.

I also can do this: IP/phppgadmin.

However, I cannot use the IP number to connect to pg using pgadmin.

It reports that the server isn't listening.

Any ideas on this?

share|improve this question

3 Answers 3

PostgreSQL by default listen only on local UNIX sockect. To enable TCP/IP endpoint uncomment in your postgresql.conf file:

listen_addresses = '*'

Where '*' - listen on all interfaces. Or put your IP number here if you want listen on specific IP only.

http://www.postgresql.org/docs/9.1/static/runtime-config-connection.html#GUC-LISTEN-ADDRESSES

share|improve this answer
    
Yes, that's exactly what I've done but it doesn't work. I tried putting my IP, then tried IP/subnet, and then tried '*' but nothing works, except localhost. –  itsols Oct 28 '12 at 16:23
    
I would add that you can use localhost instead of ip to connect using pgadmin without changing anything –  Hex Oct 28 '12 at 16:23
    
@Hex yes I can for locally testing but I'm trying to create a Lazarus (pascal) program and it will run on PCs within the LAN. So I need to be able to specify the IP to my server. –  itsols Oct 28 '12 at 16:26
    
Do you restarted your pgsql server? And check your firewall and look at output: netstat -ltpn. Is there tcp port 5432 on listen state? –  RJS Oct 28 '12 at 16:44
    
@Hex yes, it's listening on port 5432. I did not setup any firewall. And yes, both pg and apache have been restarted a few times (after config changes at least). –  itsols Oct 28 '12 at 17:09

What's the error message you get from PGAdmin? Is there anything in the logs (/var/log/postgresql.log or similar)?

I would guess you have no proper auth-setting in your pg_hba.conf, as PostgreSQL per default only allows local users via unix-sockets to connect, not via TCP which you want. You might need something like

host       all  all  0.0.0.0  pam

or

hostssl       all  all  0.0.0.0  md5

in the pg_hba.conf -- read the above link for proper documentation :)

share|improve this answer

Thank you to the different users who helped me narrow down the problem. Actually there were multiple issues. I have outline them here as a complete answer and hope someone else may benefit.

  1. like RJS said, I had to put the listen_addresses to accept multiple IPs. This was initially done but later on I realised that the line had a # in front of it which meant it was commented. So I took off the comment.

  2. Even after stopping the PG server, pg_lsclusters showed that there was still a service running. So I couldn't restart it since it reported that it was already running.

  3. Then by using ps I found that a related program known as pgpool was using the same port and it wouldn't let the default 5432 port to be used by PG. So I stopped this from the terminal using sudo pgpool stop.

  4. Then I restarted the postgres server and all was fine!

    While searching for an answer, I was told by a volunteer RhodiumToad on IRC (#postgresql) that pooling wasn't necessary for what I was doing. I was asked why I have it. The strange thing is that I never installed it. Perhaps pgpool was installed as some addition.

  5. One of the other problems was that I could not get pgadmin to start up on Windows. and correctly connect. There was a libpq.dll missing. Apparently (you'll find another post on stackoverflow about this), the file was there in a few places on Win XP. So I copied all of the postgres DLL files to Windows/System32 and it fixed that.

That's it! Hope this helps.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.