How to configure PostgreSQL to accept all incoming connections

I have a PostgreSQL database that I would like to configure to accept all incoming connections regardless of the source IP address. How can this be configured in the pg_hba.conf file? I am using postgreSQL version 8.4.

+92
postgresql
Jul 19 '10 at 3:59 a.m.
source share
4 answers

Just use 0.0.0.0/0:

host all all 0.0.0.0/0 md5 

Make sure listen_addresses in postgresql.conf also allows all incoming connections:

 listen_addresses = '*' 

After the changes, you need to reload the configuration (as root):

 SELECT pg_reload_conf(); 
+184
Jul 19 '10 at 6:20
source share

0.0.0.0/0 for all IPv4 addresses

::0/0 for all IPv6 addresses

all to match any IP address

samehost to match any serverโ€™s own IP address

samenet to match any address on any subnet to which the server is directly connected.

eg.

 host all all 0.0.0.0/0 md5 
+38
Jul 06 '16 at 14:27
source share

Complementing the excellent answers, if you want a range of IP addresses to be allowed, you can edit the file /var/lib/pgsql/{VERSION}/data and put something like

host all all 172.0.0.0/8 trust

It will accept incoming connections from any host in the above range. Source: http://www.linuxtopia.org/online_books/database_guides/Practical_PostgreSQL_database/c15679_002.htm

+4
Sep 19 '17 at 8:14
source share
 host all all all trust 
-3
Feb 14 '17 at 9:16 on
source share



All Articles