Jan 23, 2016 Configure PostgreSQL to allow remote connection. It means any attempt to connect to the postgresql server from outside the machine will be refused. We can try hitting the port 5432 by using telnet. $ telnet 107.170. Trying 107.170.11.79. Telnet: connect to address 107.170.11.79: Connection refused telnet: Unable to connect to remote host.
![Remote Remote](http://1.bp.blogspot.com/-WbjhW6PUgdQ/VadUwQeJpuI/AAAAAAAAAH4/D59Yo1hEhn0/s1600/pgsql-logo.png)
![Postgresql Postgresql](/uploads/1/2/5/4/125499113/502492320.png)
.By default, only clients running on the same machine as the PostgreSQL database cluster can connect to it. To allow remote clients to connect to the database cluster, alter the PostgreSQL pghba.conf configuration file.Follow the instructions specific to the operating system where PostgreSQL is installed. PostgreSQL is installed on a Linux server. Make a backup copy of the pghba.conf file before you alter it. If the PostgreSQL postmaster is already running, stop it using the pgctl stop command.
Open the pghba.conf file in a text editor. Add the IP addresses of connecting client machines and the client authentication methods used for connections. For example, to allow any user who supplies a valid password to connect to a database named habitat from addresses beginning with 10.2.12 using an md5 connection, add the following line to the pghba.conf file:host habitat all 10.2.12.0/24 md5If you want to allow all users who supply a valid password to connect to any of the databases on the PostgreSQL instance from addresses beginning with 100, you would add a line similar to the following to the pghba.conf file:host all all 100.0.0.0/8 md5The preceding examples were for IPV4 addresses. For example, to allow any user who supplies a valid password to connect to a database named habitat from addresses beginning with 10.2.12 using an md5 connection, add the following line to the pghba.conf file:host habitat all 10.2.12.0/24 md5If you want to allow all users who supply a valid password to connect to any of the databases on the PostgreSQL instance from addresses beginning with 100, you would add a line similar to the following to the pghba.conf file:host all all 100.0.0.0/8 md5The preceding examples were for IPV4 addresses.