I will introduce how to make PostgreSQL accessible from outside clilent. ホストOSから VirtualBox の中の PostgreSQL にアクセスする方法 の内容と重複する部分があります。
Procedure
Edit 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”.
1 |
listen_addresses = 'localhost' |
There, list all hosts you want accept the access from, as comma separated value.
1 |
listen_addresses = 'localhost,123.123.123.123' |
Or write '*'
. PostgreSQL will accept access from any IP addresses.
1 |
listen_addresses = '*' |
Next, edit hba.conf
. It is in the same directory as postgresql.conf
is in.
1 2 |
# IPv4 local connections: host all all remote_client_ip_address/32 trust |
Set appropriate IP address to remote_client_ip_address
.
At last, restart PostgreSQL.
- Arch Linux
-
1systemctl restart postgresql.service
- Ubuntu
-
1sudo service postgresql restart
- MacOS
-
12launchctl unload /usr/local/Cellar/postgresql/VERSION/homebrew.mxcl.postgresql.plistlaunchctl load /usr/local/Cellar/postgresql/VERSION/homebrew.mxcl.postgresql.plist
- MacOS with Homebrew
1 |
brew services restart postgresql |