Skip to content

Allow Remote Postgres Cluster Access

Allow Remote Postgres Cluster Access#

  1. Listen on remote ips

    sudo vim /etc/postgresql/<version>/main/postgresql.conf
    

    Set:

    listen_addresses = '*'
    

    One could limit it to a specific subnet or ip

    Your config file can be viewed with sudo -u postgres psql -c "SHOW config_file;"

  2. Modify pg_hba.conf

    sudo vim /etc/postgresql/<version>/main/pg_hba.conf
    

    Set:

    host    all             all             0.0.0.0/0            md5
    
  3. Allow port 5432 on the firewall

    sudo ufw allow 5432/tcp
    
  4. Restart postgres

    sudo systemctl restart postgresql
    

https://blog.devart.com/configure-postgresql-to-allow-remote-connection.html https://stackoverflow.com/questions/18580066/how-to-allow-remote-access-to-postgresql-database https://tecadmin.net/postgresql-allow-remote-connections/