Help us understand the problem. What is going on with this article?

could not load pg_hba.conf でハマった

More than 3 years have passed since last update.

TL;DR

  • pg_hba.confのIPアドレスはCIDR表記( / つけるやつ)にしないといけない

記事

外部ホスト192.0.2.1からの接続を許可したく、pg_hba.confに下記のように書いた。

# TYPE  DATABASE        USER            ADDRESS                 METHOD
host    all             hogeuser        192.0.2.1               password

そしてサービススタート……。

$ sudo service postgresql-9.5 start
Starting postgresql-9.5 service:                           [FAILED]

とするが失敗。CentOS6のyumにリポジトリを追加してPostgreSQL 9.5をインストールしていた私の環境では、ログファイルは /var/lib/pgsql/9.5/data/pg_log/ にあった。

< 2016-02-10 00:16:18.210 JST >CONTEXT:  line 86 of configuration file "/var/lib/pgsql/9.5/data/pg_hba.conf"
< 2016-02-10 00:16:18.210 JST >FATAL:  could not load pg_hba.conf

接続元のIPアドレスを下記のようにCIDR表記に変更して解決。

# TYPE  DATABASE        USER            ADDRESS                 METHOD
host    all             hogeuser        192.0.2.1/32            password

そのIPアドレスからだけ接続を受け付けるなら何も考えずうしろに /32 をつければOK。

Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away