Categories

Tuesday 1 October 2013

Unable to connect to remote host: No route to host for postgresql

Hi,

When trying to connect to an postgresql database from outside, you may get the error as below " Unable to connect to remote host: No route to host for postgresql"

Here Iam using the postgresql version 9.3
Steps to check

1) First check the iptables rules on the server. If there is any unusual logs then flush it or try after stopping the iptables service using the command

/etc/init.d/iptables stop

2)Even after this if you are still unable to connect to the postgresql server, then do check the following

The postgresql default data directory in linux is   /var/lib/pgsql/9.3/data/

The configuration file for the service is postgresql.conf.

Open that file and search for the option  listen_addresses and make it to listen on all of the interfaces or IPs on that machine as below.

 listen_addresses = '*'

Now exit the configuration file after saving it.

3)Then go the configuration file  pg_hba.conf in the data directory /var/lib/pgsql/9.3/data/

This file controls the connection information of postgresql.

Open that file  and edit the configuration options as below

# IPv4 local connections:
host    all         all         127.0.0.1/32          trust
host    all             all             192.168.0.0/16            trust
# IPv6 local connections:

Above configuration will make the postgresql to listen on all hosts with the subnet range 192.168.0.0/16 . So add it based on your requirement.

Now save the file and then restart the postgresql database using the below command.

/etc/init.d/postgresql restart

Now try to connect to the database.

Also check for any startup errors on the log file /var/lib/pgsql/9.3/pgstartup.log


Regards
Syamkumar.M




No comments:

Post a Comment

Ad