Make PostgreSQL Accessible from Outside


I will introduce how to make PostgreSQL accessible from outside clilent. ホストOSから VirtualBox の中の PostgreSQL にアクセスする方法 の内容と重複する部分があります。

Procedure

Edit postgresql.conf.

Location of postgresql.conf
Arch Linux /var/lib/postgres/data/postgresql.conf
Ubuntu /etc/postgresql/VERSION/main/postgresql.conf
MacOS /usr/local/var/postgres/postgresql.conf

First, add “ListenAddress”.

There, list all hosts you want accept the access from, as comma separated value.

Or write '*'. PostgreSQL will accept access from any IP addresses.

Next, edit hba.conf. It is in the same directory as postgresql.conf is in.

Set appropriate IP address to remote_client_ip_address.

At last, restart PostgreSQL.

Arch Linux
Ubuntu
MacOS
MacOS with Homebrew