postgresqlrhel7kong

Kong won't connect to PostgreSQL


I'm not using Docker.

I've installed PostgreSQL 11 and created a user kong that owns a database kong. On the same linux box I've installed Kong, and am trying to get it to connect to the DB using these instructions.

Here's a snippet from kong.conf:

database = postgres
pg_host = 127.0.0.1
pg_port = 5432
pg_timeout = 5000
pg_user = kong
pg_password = Passw0rd!
pg_database = kong

Also, per this, I've modified pg_hba.conf to include:

# TYPE  DATABASE        USER            ADDRESS                 METHOD
local   all             all                                     trust
host    all             all             127.0.0.1/32            trust

Still, when I do:

kong migrations bootstrap -c /etc/kong/kong.conf

I get:

Error: [PostgreSQL error] failed to retrieve server_version_num: FATAL: Ident authentication failed for user "kong"

I've made sure PostgreSQL has the same password for kong that is in the kong.conf.

What am I missing?


Solution

  • Got it working. Two things:

    1. At the advice of @DanielVérité on Server Fault, I moved my trust methods to the top on pg_hba.conf. This is because he noted that the first match is what PostgreSQL goes with.

    2. In kong.conf, I thought I'd specified pg_host = 127.0.0.1, but I'd actually put the host name in there. Changed it back to 127.0.0.1 and it now works.

    I hope this helps someone down the road.