I'm trying to remotely connect to my postgresql database. I have two virtual machines set up both running ubuntu 14.04. I am trying to connect to the second vm using the first vm using

psql -h -U postgres -d postgres

But I receive the error:

Could not connect to server: Connection refused
    Is the server running on host "" and accepting
    TCP/IP connections on port 5432?

I have changed the pg_hba.conf and added

host all all md5
host all all * md5
host all all md5

And changed the postgresql.conf listen_address=" * "

In an attempt to allow all incoming connections. I have also tried to change the firewall settings, but I am unsure of whether or not the ports are properly listening for the connection.

  • 1
    Hi Jonathan! Welcome to Stack Overflow! Here most of the questions are related with development, you may probably want to try this question on a community like SuperUser.
    – Alpha
    Commented Aug 19, 2014 at 20:33

1 Answer 1


Apparently the problem was in the postgresql.conf the listen_addresses line had the # still in front of it making it a comment. Removing it solved my problems.

  • # symbol (comment) wasted around 3 hours of mine while allowing other computers to connect to it. Thanks for your answer. It helped to fulfill the task.
    – vivek
    Commented Jul 26, 2016 at 10:13

Your Answer

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