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

I'm trying to set up a postgres server, but I cannot access it through the Internet. It works fine on my LAN. Server is just a desktop computer using Ubuntu 12.04 desktop.

disclaimer: I am not planning to use this configuration permanently. Ultimately I will connect through an SSH tunnel and some of what I'm doing could be unsecure, but right now I just want to figure out why it's not working.

In my postgresql.conf file, I set listen_addresses = '*'. To test that it wasn't something with my pg_hba.conf, I commented everything and just used

host all all all trust

There doesn't seem to be anything happening with the firewall - to make sure I installed gufw and allowed all incoming and outgoing traffic on both the server and client.

When I try to connect through my domain name, which points to the server's outside IP address, I get this message:

psql: could not connect to server: Connection refused
Is the server running on host "<hostname>" (<IP address>) and accepting
TCP/IP connections on port 5432?

The result of netstat -an | grep 5432 seems to indicate that postgres is indeed listening for connections on all addresses:

tcp        0      0 0.0.0.0:5432            0.0.0.0:*               LISTEN     
tcp6       0      0 :::5432                 :::*                    LISTEN     
unix  2      [ ACC ]     STREAM     LISTENING     9771     /var/run/postgresql/.s.PGSQL.5432
share|improve this question
add comment

1 Answer 1

a line in pg_hba.conf, for e. g.:

host all all 0.0.0.0/0 md5

share|improve this answer
    
Isn't that more restrictive than what I had put in my pg_hba? I thought what I had caused it to trust every connection. –  buck Jun 8 '12 at 21:04
1  
Reading the doc would help you understand things correctly — there's no "all" for IP addresses. But 0.0.0.0/0 notation means any IP-addr. trust for every IP-addr is too insecure, that's why I put "md5" there, but it's up to you. –  poige Jun 9 '12 at 2:06
    
Thanks for the suggestion, but this didn't fix the problem, I still can't connect. –  buck Jun 9 '12 at 21:37
1  
@buck, firewall? :) –  poige Jun 10 '12 at 3:07
add comment

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.