Enable remote access for PostgreSQL
By default, the PostgreSQL, server listens only on the local interface 127.0.0.1.
If you want to connect to the PostgreSQL server from remote locations, you need to set the server to listen on the public interface and edit the configuration to accept remote connections.
Open the configuration file
postgresql.confand addlisten_addresses = '*' in the CONNECTIONS AND AUTHENTICATIONsection. This instruct the server to listen on all network interfaces.
sudo vim /etc/postgresql/11/main/postgresql.conf#------------------------------------------------------------------------------
# CONNECTIONS AND AUTHENTICATION
#------------------------------------------------------------------------------
# - Connection Settings -
listen_addresses = '*' # what IP address(es) to listen on;Save the file and restart the PostgreSQL service for changes to take effect:
sudo systemctl restart postgresqlVerify changes:
ss -nlt | grep 5432LISTEN 0 128 0.0.0.0:5432 0.0.0.0:*
LISTEN 0 128 [::]:5432 [::]:*Last updated