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:

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

host    all         mydbuser         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


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.

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

3 Answers 3


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 (this is the allowed range in your pg_hba.conf)?

Can you ping

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.

  • 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

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

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

host all mydbuser md5

this line in your pg_hba.conf means that only the user mydbuser from host 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 to connect, you'd put

  • 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 .