1

Well I seem to have tried everything I can find - not that much - but cannot fathom why I cannot get a remote connection to my database.

Here's what I have:

#postgresql.conf
listen_addresses = '12.34.56.78,localhost' # included my local ip
port = 5432                                # the port I'm trying to connect with
tcpip_socket = true                        

#pg_hba.conf
host    all         mydbuser       12.34.56.78/32         md5

I receive: connection to database 'name' failed, could not connect to server: Connection refused.
 Is the server running on host "domain.com" and accepting
 TCP/IP connections on port 5432?

netstat -ant | grep 5432 #returns nothing 

netstat -nltp | grep 5432: returns nothing

Solution

Really I think what was holding me back from grasping an understanding of this was a poorly written blog post on the subject. On the other hand an awesome tutorial at slice host cleared things up for me and if anyone ever comes here having the same problems I suggest they read through it. Slicehost really have to be commended on the quality and maintenance of their tutorials, though I guess it is good business to help people use their service.

Thank you to everyone who answered.

1
  • Same result I'm afraid.
    – mark
    Dec 20, 2010 at 14:39

3 Answers 3

1

On the db server could you run the following and post the output:

  • ps axf | grep postgres
  • the listening port netstat -nltp | grep 5432

To get around firewalls try using port 80 or 8080 instead of 5432.

Are you connecting from 12.34.56.78/32 (this is the allowed range in your pg_hba.conf)?

Can you ping 12.34.56.78?

From the empty netstat output, looks like your postgres process is not listening on the port!

Does anything interesting show up in /var/log/postgresql/ when you restart the database.

5
  • Thanks Aleksandr Have done. Have access to firewall if need to change anything though I believe there are no current rules.
    – mark
    Dec 20, 2010 at 14:32
  • The ip is correct.
    – mark
    Dec 20, 2010 at 14:36
  • Have added answer to your latter questions in the op. Thanks again for continued help.
    – mark
    Dec 20, 2010 at 15:39
  • Thanks Aleksandr. Your answer led me to look in the right places.
    – mark
    Dec 20, 2010 at 20:34
  • Cool! Can you point to where the problem was? Dec 21, 2010 at 20:26
1

Have you checked your firewall? You could have some rule preventing access to that port

1
  • Hi phsr, have edited my question if you could please check it over.
    – mark
    Dec 20, 2010 at 14:15
1

host all mydbuser 12.34.56.78/32 md5

this line in your pg_hba.conf means that only the user mydbuser from host 12.34.56.78 will be able to connect.

So if this is the PG server, you'll need to add another line for the host or the subnet (i.e., if you want any of 12.34.45.01-254 to connect, you'd put 12.34.56.00/24)

1
  • Hi Glen. Thanks for your answer. I only need localhost and one login from my development machine in order that I can perform backups.
    – mark
    Dec 20, 2010 at 18:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .