Postgresql connection refused

connectivitypostgresqlUbuntu

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 10.0.1.23 -U postgres -d postgres

But I receive the error:

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

I have changed the pg_hba.conf and added

host all all 10.0.1.64/24 md5
host all all * md5
host all all 0.0.0.0/0 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.

Best Answer

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.