backend/sql (postgres)

다른 서버에서 postgres 접속하기 (5432 포트)

seul chan 2017. 10. 21. 21:00

Access other server postgres

In postgres server

  1. finding pg_hab.conf

you can find with next command

# login with sudo user
# you can skip but you have to write sudo command
sudo -s

# finding pg_hba
find / -type f -name "pg_hba.conf"
  1. edit setting in pg_hab.conf
    # go to pg_hab.conf dir
    # it's different between psql install dir
    cd /etc/postgresql/9.3/main
    # open pg_hba.conf
    vim pg_hba.conf
    

    Add following line in ip address of client machine

    host all all x.x.x.x/24 trust
    
  2. edit postgresql.conf
    vim postgresql.conf
    

    Add wildcardw in listen address

    maybe there’s already listen_address setting and you have to find with / and change to next setting

    listen_addresses = '*'
    
  3. restart postgresql
    # you can use other command to restart
    sudo service restart postgresql
    

If using aws, you should open security group: TCP: 5432