others-how to allow remote connections to access postgresql 13 ?

1. Purpose

I would demonstrate how to allow postgresql 13 to accept connections from remote ip addresses.

2. The solution

1) Find the postgresql config file

sudo -u postgres psql -c "SHOW config_file;" 

Got this result:

 ⚡ root@launch-advisor-20191120  ~  sudo -u postgres psql -c "SHOW config_file;"
               config_file
-----------------------------------------
 /etc/postgresql/13/main/postgresql.conf
(1 row)

Then change the content of the file: /etc/postgresql/13/main/postgresql.conf :

#------------------------------------------------------------------------------
# CONNECTIONS AND AUTHENTICATION
#------------------------------------------------------------------------------

# - Connection Settings -

listen_addresses = '*'      # what IP address(es) to listen on;
                    # comma-separated list of addresses;
                    # defaults to 'localhost'; use '*' for all
                    # (change requires restart)
port = 5432             # (change requires restart)
max_connections = 100           # (change requires restart)

The key point is :

listen_addresses = '*'

which would let postgresql listen to all network interfaces.


3. Summary

In this post, I demonstrated how to allow remote connections to access postgresql 13 . That’s it, thanks for your reading.