1

Hope this is not as stupid a question as I think it is. But I'm in a loop and unable to find a solution.

I installed Postgres in centos machine. The installation worked fine (apparently). Now I have 3 Linux users - root, admin and postgres. In order to allow all connections I updated the pg_hba.conf file with necessary changes. Now, if I try to restart (from root or postgres user), I get below error:

-bash-4.2$ systemctl start postgresql-9.5.service
  ==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===              
 Authentication is required to manage system services or units. 
 Authenticating as: Admin (admin) Password:
 ==== AUTHENTICATION COMPLETE === Job for postgresql-9.5.service failed 
 because the control process exited with error code. See "systemctl status 
 postgresql-9.5.service" and "journalctl -xe" for details.

Please find below outputs:

-bash-4.2$ journalctl -xe 
Hint: You are currently not seeing messages from other users and the system.
  Users in the 'systemd-journal' group can see all messages. Pass -q to
  turn off this notice. No journal files were opened due to insufficient permissions.


-bash-4.2$ systemctl status postgresql-9.5.service 
 ● postgresql-9.5.service - PostgreSQL 9.5 database server    Loaded: loaded (/usr/lib/systemd/system/postgresql-9.5.service; enabled; vendor preset: disabled)    **Active: failed** (Result: exit-code) since Wed 2018-07-25 12:58:51 IST; 1min 26s ago
 Docs: https://www.postgresql.org/docs/9.5/static/   Process: 109849 **ExecStart=/usr/pgsql-9.5/bin/pg_ctl start -D ${PGDATA} -s -w -t 300 (code=exited, status=1/FAILURE)**   Process: 109843 ExecStartPre=/usr/pgsql-9.5/bin/postgresql95-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)  Main PID: 102339 (code=exited, status=0/SUCCESS)

I searched further and various links (most notably this ) pointed to the fact that I needed to run something like the below, which I did:

/usr/pgsql-9.5/bin/postgresql95-setup initdb

But that would give error:

Data directory is not empty!

The only way out of this is to delete the directory /var/lib/pgsql/9.5/data completely, which would leave me with no DB and no pg_hba.conf

pg_hba.conf:

Relevant part of pg_hba.conf

Relevant error messages:

2018-07-25 12:53:06.218 IST >LOG: invalid authentication method "0.0.0.0/0" < 
2018-07-25 12:53:06.218 IST >CONTEXT: line 80 of configuration file "/var/lib/pgsql/9.5/data/pg_hba.conf" < 
2018-07-25 12:53:06.218 IST >FATAL: could not load pg_hba.conf < 
2018-07-25 12:58:50.617 IST >LOG: invalid authentication method "0.0.0.0/0" < 
2018-07-25 12:58:50.617 IST >CONTEXT: line 80 of configuration file "/var/lib/pgsql/9.5/data/pg_hba.conf" < 
2018-07-25 12:58:50.617 IST >FATAL: could not load pg_hba.conf

closed as off-topic by Colin 't Hart, Philᵀᴹ, hot2use, Md Haidar Ali Khan, mustaccio Jul 25 '18 at 12:43

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Too localized - this could be because your code has a typo, basic error, or is not relevant to most of our audience. Consider revising your question so that it appeals to a broader audience. As it stands, the question is unlikely to help other users (regarding typo questions, see this meta question for background)." – Philᵀᴹ, hot2use, mustaccio
If this question can be reworded to fit the rules in the help center, please edit the question.

  • What errors appear in the Postgres log files? What changes did you make to pg_hba.conf? Does it work if you revert the changes? – Colin 't Hart Jul 25 '18 at 7:56
  • @Colin'tHart Below is my pg_hba.conf relevant lines: # TYPE DATABASE USER ADDRESS METHOD # "local" is for Unix domain socket connections only local all all 0.0.0.0/0 md5 – Pratik Ray Jul 25 '18 at 8:03
  • 1
    If that’s all you have in the file then it’s not going to work. Read the comments. Restore the original and try again. – Colin 't Hart Jul 25 '18 at 8:05
  • And below are logs (seems the issue is connected to my changes): < 2018-07-25 12:53:06.218 IST >LOG: invalid authentication method "0.0.0.0/0" < 2018-07-25 12:53:06.218 IST >CONTEXT: line 80 of configuration file "/var/lib/pgsql/9.5/data/pg_hba.conf" < 2018-07-25 12:53:06.218 IST >FATAL: could not load pg_hba.conf < 2018-07-25 12:58:50.617 IST >LOG: invalid authentication method "0.0.0.0/0" < 2018-07-25 12:58:50.617 IST >CONTEXT: line 80 of configuration file "/var/lib/pgsql/9.5/data/pg_hba.conf" < 2018-07-25 12:58:50.617 IST >FATAL: could not load pg_hba.conf – Pratik Ray Jul 25 '18 at 8:06
  • The problem is a parse error in your configuration file – Philᵀᴹ Jul 25 '18 at 8:09
0

From the documentation:

A record can have one of the seven formats

local database user auth-method [auth-options] host
database user address auth-method [auth-options] hostssl
database user address auth-method [auth-options] hostnossl database user address auth-method [auth-options] host
database user IP-address IP-mask auth-method [auth-options] hostssl database user IP-address IP-mask auth-method [auth-options] hostnossl database user IP-address IP-mask auth-method [auth-options]

Your line:

local all all 0.0.0.0/0 md5

.. does not match any of these.

I suspect you want one of these instead:

host all all 0.0.0.0/0 md5

or:

local all all md5
  • Thanks a lot @Phil. "host all all 0.0.0.0/0 md5" is working and DB started fine. I'm accepting your answer. Thanks again! – Pratik Ray Jul 25 '18 at 9:17

Not the answer you're looking for? Browse other questions tagged or ask your own question.