Open the PostgreSQL configuration file postgresql.conf
Then, find the line #listen_addresses = 'localhost'
and uncomment it (remove the # character at the beginning of the line).
listen_addresses = '*'
Next, change the value of listen_addresses
to *
. This allows PostgreSQL to listen on all available IP addresses. Alternatively, you can specify a specific IP address or a range of IP addresses that are allowed to connect to the server.
Open the pg_hba.conf
Take the following section:
# IPv4 local connections: host all all 127.0.0.1/32 trust
And modify it this way:
# IPv4 local connections: host all all 0.0.0.0/0 md5
To enable traffic on port 5432 through the firewall, execute the following command: sudo ufw allow 5432/tcp
Run the following command to restart PostgreSQL: /etc/rc.d/postgresql restart
Ejecutar psql en el servidor y luego el comando indicado:
root@server:~ # su - postgres postgres@server:~ $ psql psql (9.6.24) Type "help" for help. postgres=# ALTER USER postgres WITH PASSWORD 'xxxxx'; ALTER ROLE postgres=# \q postgres@server:~ $ exit logout root@server:~ # _