--- lang: ja-jp breaks: true --- # PostgreSQL 外部からの接続を許可する設定 2021-04-28 ## pg_hba.conf ```shell= $ su # vim /etc/postgresql/12/main/pg_hba.conf # 以下の行を追加 host all all 0.0.0.0/0 md5 ``` 以下、設定内容の全体 ```shell= # Database administrative login by Unix domain socket local all postgres peer # TYPE DATABASE USER ADDRESS METHOD # "local" is for Unix domain socket connections only local all all peer # IPv4 local connections: host all all 127.0.0.1/32 md5 host all all 0.0.0.0/0 md5 # IPv6 local connections: host all all ::1/128 md5 # Allow replication connections from localhost, by a user with the # replication privilege. local replication all peer host replication all 127.0.0.1/32 md5 host replication all ::1/128 md5 ``` ## postgresql.conf ``` # vim /etc/postgresql/12/main/postgresql.conf ``` ``` listen_addresses = '*' # what IP address(es) to listen on; ``` ## PostgreSQLの再起動 ```shell= /etc/init.d/postgresql restart ``` ###### tags: `PostgreSQL`