This question has been flagged
2 Replies
7138 Views
Best Answer

Step 1.

Add the following line to the pg_hba.conf server. This will allow connection from “192.168.0.100″ ip-address (This is the client ip address in our example). 

postgres 9.3

# vi /etc/postgresql/9.3/main/pg_hba.conf 

host all all 192.168.0.100/24 trust

postgres 9.1

# vi /etc/postgresql/9.1/main/pg_hba.conf 

host all all 192.168.0.100/24 trust

If you want to allow connection from any client machines on your network, specify the network address here in the CIDR-address format.

host all all 192.168.0.0/24 trust

Step 2.

On the PostgreSQL database server, by default, the listen address will be localhost in the postgresql.conf file as shown below.

# grep listen /etc/postgresql/9.1/main/postgresql.conf 

       #listen_addresses = 'localhost'

Modify this line and give *. If you have multiple interfaces on the server, you can also specify a specific interface to be listened.

# vi /etc/postgresql/9.1/main/postgresql.conf

      listen_addresses = '*'

Step 3.

service postgresql restart

Avatar
Discard
Best Answer

By default PostgreSQL does not allow remote servers to connect to it. So, you will have to allow your IP address in the trust IP list.  If you have dynamic IP address which keeps on changing then you will have to keep on updating the IP address.

Avatar
Discard

And if I want to allow any IP adress to connect, I'll avoid changing IP adress, But this is a security issue.