Search code examples
postgresqlpgadmin

Allow access to Postgresql from any computer


After researching GUI's for Postgresql I found the pgadmin 4 desktop client to be a valid choice.

I use an Ubuntu 16.04 server (droplet on Digital Ocean) and iptables firewall.

How do I allow access from remote computers? My computers with pgadmin installed have dynamic ip's.


Solution

  • I wanted to connect to my cloud hosted Postgresql database from remote desktop computers with a client such as pgadmin.

    To achieve this I opened up port 5432 in iptables by the following commands:

    iptables -I INPUT 1 -m tcp -p tcp --dport 5432 -j ACCEPT 
    service iptables save 
    service iptables restart  
    

    I allowed access from any location in Postgresql like so:

    nano /etc/postgresql/9.5/main/postgresql.conf
    

    Edit listen_address like so:

    listen_addresses = '*'
    

    save and close nano editor and execute the postgresql restart command

    service postgresql restart