Difference between revisions of "PostgreSQL pg hba.conf"

From wikieduonline
Jump to navigation Jump to search
Line 7: Line 7:
 
  listen_addresses
 
  listen_addresses
 
  listen_addresses 0.0.0.0
 
  listen_addresses 0.0.0.0
 +
 +
 +
== Remote communication ==
 +
cat /etc/postgresql/12/main/[[pg_hba.conf]] | grep -v "#" | grep .
 +
local  all            postgres                                peer
 +
local  all            all                                    peer
 +
host    all            all            127.0.0.1/32            md5
 +
host    all            all            ::1/128                md5
 +
local  replication    all                                    peer
 +
host    replication    all            127.0.0.1/32            md5
 +
host    replication    all            ::1/128                md5
 +
 +
 +
To allow remote communications from all [[IP]]s <ref>https://stackoverflow.com/questions/18580066/how-to-allow-remote-access-to-postgresql-database</ref>:
 +
/etc/postgresql/12/main/[[pg_hba.conf]]
 +
local  all            postgres                                peer
 +
local  all            all                                    peer
 +
host    all            all            '''0.0.0.0/0'''              md5
 +
host    all            all            '''::/0'''                    md5
 +
local  replication    all                                    peer
 +
host    replication    all            127.0.0.1/32            md5
 +
host    replication    all            ::1/128                md5
  
 
== Related terms ==
 
== Related terms ==

Revision as of 15:34, 5 March 2021


https://www.postgresql.org/docs/11/runtime-config-connection.html#RUNTIME-CONFIG-CONNECTION-SETTINGS

listen_addresses
listen_addresses 0.0.0.0


Remote communication

cat /etc/postgresql/12/main/pg_hba.conf | grep -v "#" | grep .
local   all             postgres                                peer
local   all             all                                     peer
host    all             all             127.0.0.1/32            md5
host    all             all             ::1/128                 md5
local   replication     all                                     peer
host    replication     all             127.0.0.1/32            md5
host    replication     all             ::1/128                 md5


To allow remote communications from all IPs [1]:

/etc/postgresql/12/main/pg_hba.conf 
local   all             postgres                                peer
local   all             all                                     peer
host    all             all             0.0.0.0/0               md5
host    all             all             ::/0                    md5
local   replication     all                                     peer
host    replication     all             127.0.0.1/32            md5
host    replication     all             ::1/128                 md5

Related terms

See also

  • https://stackoverflow.com/questions/18580066/how-to-allow-remote-access-to-postgresql-database
  • Advertising: