Set PostGreSQL to accept remote access

Step # 1: Enable client authentication

Edit the PostgreSQL configuration file /var/lib/pgsql/data/pg_hba.conf:

# TYPE DATABASE USER CIDR-ADDRESS METHOD

# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 trust
host all all 10.14.0.0/0 password
# IPv6 local connections:
host all all ::1/128 password

Save and close the file.

Step # 2: Enable networking for PostgreSQL: Allow TCP/IP socket

If you are using PostgreSQL version 8.x or newer use the following instructions or skip to Step # 3a for older version (7.x or older).

You need to open PostgreSQL configuration file /var/lib/pgsql/data/postgresql.conf

In this file change the following:

listen_addresses='localhost'

to

listen_addresses='*'

Step # 3 Restart PostgreSQL Server

Type the following command:
# /etc/init.d/postgresql restart

Step # 4: Iptables firewall rules

Make sure iptables is not blocking communication, open port 5432 (append rules to your iptables scripts or file /etc/sysconfig/iptables):

put this line in the iptables,

-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 5432 -j ACCEPT

But it must before this line,

-A RH-Firewall-1-INPUT -j REJECT --reject-with icmp-host-prohibited

Restart firewall:
# /etc/init.d/iptables restart
Step # 6: Test your setup

Modified from http://www.cyberciti.biz/tips/postgres-allow-remote-access-tcp-connection.html

**Try to disable the Iptable if you still can not work it out.

No comments:

Post a Comment

Datatable static image not found on the server

When you use ```datatables.min.css``` and ```datatables.min.js``` locally, instead of datatables CDN, you may have encountered that ```sort...